Topic: size and length


Author: horstman@jupiter.SJSU.EDU (Cay Horstmann)
Date: 1995/09/05
Raw View
The number of elements in a vector is obtained by size(), the number of
elements in a valarray by length() and the number of characters in a
string by, you guessed it, either size() or length(). All other STL
containers use size(). (There is also a length(const char[]) function in
ios_traits, but it is not terribly related to this discussion.)

Has the library workgroup spent any conscious thought on this weighty
issue, or is all this just an accident? The obvious fix would be to add
size(0 as a synonym to length() in valarrays.

Cay
horstman@cs.sjsu.edu
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]