The class template basic_string provides typical string-manipulation operations such as copying, searching, etc. The template definition and all support facilities are defined in namespace std
; these include the typedef
statement
typedef basic_string< char > string;
that creates the alias type string
for basic_string<char>. A typedef
is also provided for the wchar_t type (wstring
). Type wchar_t
1 stores characters (e.g., two-byte characters, four-byte characters, etc.) for supporting other character sets. We use string
exclusively throughout this chapter. To use string
s, include header <string>
.
1. Type wchar_t
commonly is used to represent Unicode®, but wchar_t
’s size is not specified by the standard. C++11 also has types char16_t
and char32_t
for Unicode support. The Unicode Standard outlines a specification to produce consistent encoding of the world’s characters and symbols. To learn more about the Unicode Standard, visit www.unicode.org
.