0% found this document useful (0 votes)
21 views

Strings Library - Cppreference

C++ Strings Library - Cppreference

Uploaded by

IoakeimTziakos
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Strings Library - Cppreference

C++ Strings Library - Cppreference

Uploaded by

IoakeimTziakos
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Strings library

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>

template<> class char_traits<char>;


template<> class char_traits<wchar_t>;
template<> class char_traits<char16_t>;
template<> class char_traits<char32_t>;

(sinc e C++11)
(sinc e C++11)

Conversions and classication


The localizations library provides s upport for s tring convers ions (e.g. std::wstring_convert or
std::toupper) as well as functions that clas s ify characters (e.g. std::isspace or std::isdigit).

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"

You might also like