Strings of characters in C++ are commonly represented using the basic_string class. C++ also provides functions for manipulating C-style strings, which are null-terminated arrays of characters.
Header <string> defines class template basic_string that generalizes the way how sequences of characters are manipulated and stored. It is defined as follows:
template< typename CharT, typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT> > > class basic_string;
Also, several specializations of the class basic_string are provided:
typedef basic_string<char> string; typedef basic_string<wchar_t> wstring; typedef basic_string<char16_t> u16string; //C++0x feature typedef basic_string<char32_t> u32string; //C++0x feature
| getline | read data from an I/O stream into a string |
The header <string> provides the following functions performing numeric conversion functions:
| stoi, stol, stoll, stoul, stoull | converts the given string to an integer (C++0x feature) |
| stof, stod, stold | converts the given string to an floating point value (C++0x feature) |
| to_string | converts the given integral or floating point value to string (C++0x feature) |
| to_wstring | converts the given integral or floating point value to wstring (C++0x feature) |
The header <string> provides the following specializations of class template hash (see hash)
hash<string> | template specialization, providing hash support for string string type (C++0x feature) |
hash<wstring> | template specialization, providing hash support for wstring string type (C++0x feature) |
hash<u16string> | template specialization, providing hash support for u16string string type (C++0x feature) |
hash<u32string> | template specialization, providing hash support for u32string string type (C++0x feature) |
Strings library provides char_traits, a template class, defining types and functions for a character container. Several specializations are defined in header <string>:
char_traits<char> | template specialization, defining operations with char character type |
char_traits<wchar_t> | template specialization, defining operations with wchar_t character type |
char_traits<char16_t> | template specialization, defining operations with char16_t character type (C++0x feature) |
char_traits<char32_t> | template specialization, defining operations with char32_t character type (C++0x feature) |