The C++ strings library includes support for three general types of strings:
- std::basic_string - a templated class designed to manipulate strings of any character type.
- std::basic_string_view (C++17) - a lightweight non-owning read-only view into a subsequence of a string.
- Null-terminated strings - arrays of characters terminated by a special null character.
The templated class std::basic_string generalizes how sequences of characters are manipulated and stored. String creation, manipulation, and destruction are all handled by a convenient set of class methods and related functions.
Several specializations of std::basic_string are provided for commonly-used types:
Null-terminated strings are arrays of characters that are terminated by a special null character. C++ provides functions to create, inspect, and modify null-terminated strings.
There are three types of null-terminated strings:
The string library also provides class template std::char_traits that defines types and functions for std::basic_string. The following specializations are defined:
|template<> class char_traits<char>;
template<> class char_traits<wchar_t>;
template<> class char_traits<char32_t>;
template<> class char_traits<char16_t>;
Conversions and classification
The localizations library provides support for string conversions (e.g. std::wstring_convert or std::toupper) as well as functions that classify characters (e.g. std::isspace or std::isdigit).