Strings Library - Cppreference
Strings Library - Cppreference
The C++ s trings library includes s upport for two general types of s trings :
std::basic_string- a templated clas s des igned to manipulate s trings of any character type.
Null-terminated s trings - arrays of characters terminated by a s pecial null character.
std::basic_string
The templated clas s std::basic_stringgeneralizes how s equences of characters are manipulated and
s tored. String creation, manipulation, and des truction are all handled by a convenient s et of clas s
methods and related functions .
Several s pecializations of std::basic_stringare provided for commonly-us ed types :
Dened in header <string>
Type
Denition
std::string
std::basic_string<char>
std::wstring
std::basic_string<wchar_t>
std::u16string std::basic_string<char16_t>
std::u32string std::basic_string<char32_t>
Null-terminated strings
Null-terminated s trings are arrays of characters that are terminated by a s pecial null character. C++
provides functions to create, ins pect, and modify null-terminated s trings .
There are three types of null-terminated s trings :
null-terminated byte s trings
null-terminated multibyte s trings
null-terminated wide s trings
Additional support
std::char_traits
The s tring library als o provides clas s template std::char_traitsthat denes types and functions for
std::basic_string. The following s pecializations are dened:
Dened in header <string>
(sinc e C++11)
(sinc e C++11)
See also
C++ documentation for Localizations library
C documentation for Strings library
Retrieved from "http://en.c ppreferenc e.c om/mwiki/index.php?title=c pp/string& oldid=82069"