std::string length() and size() member functions

As per the documentation, these are just synonyms. size() is there to be consistent with other STL containers (like vector, map, etc.) and length() is to be consistent with most peoples’ intuitive notion of character strings. People usually talk about a word, sentence or paragraph’s length, not its size, so length() is there to make things more readable.

Leave a Comment