String Varieties
This section treats the string class as if it were based on the char type. In fact, as mentioned earlier, the string library really is based on a template class:
template<class charT, class traits = char _traits<charT>, class Allocator = allocator<charT> >basic_string {...};
The basic_string template comes with four specializations, each of which has a typedef name:
typedef basic_string<char> string;typedef basic_string<wchar_t> wstring;typedef basic_string<char16_t> u16string; // C++11typedef basic_string<char32_t> u32string ; // C++11
This allows you to use strings based on the wchar_t, char16_t, and char32_t types as well as the char type. You could even develop some sort of character-like class and use the basic_string ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access