It was designed as a string class (hence, for example, length() and all these dozens of search functions), but after introducing STL into std lib, it was also an STL container (hence, size() and iterators, with <algorithm> doing all the functions search redundant).
However, the main goal is to keep the characters. Using nothing but POD does not guarantee operation (and does not work, for example, when using Dinkumware std lib). In addition, the optional std::char_traits should not be available for anything other than char and wchar_t (although many implementations have a reasonable implementation of the base template).
In the original standard, the class was not supposed to store its data in the contiguous portion of memory, but this has changed from C ++ 03.
In short, it is mostly useful as a container of characters (aka "string"), where "character" has a fairly broad definition.
The βwildestβ I used it with is to store differently encoded strings using different types of characters. Thus, strings of different encodings are incompatible, even if they use the same character size (ASCII and UTF-8), and, for example, the destination causes compile-time errors.
source share