Strings library

From Cppreference

< cpp
Jump to: navigation, search

Contents

[edit] Null terminated narrow string management

[edit] Null-terminated wide string management

[edit] basic_string

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:

Defined in header <ostream>
Type Definition
string ​basic_string<char>
wstring ​basic_string<wchar_t>
u16string ​basic_string<char16_t>
u32string ​basic_string<char32_t>

Functions

getline
read data from an I/O stream into a string
(function)
Numeric conversions
stoi
stol
stoll
stoul
stoull
(C++0x)
(C++0x)
(C++0x)
(C++0x)
(C++0x)
converts the given string to an integer
(function)
stof
stod
stold
(C++0x)
(C++0x)
(C++0x)
converts the given string to an floating point value
(function)
to_string (C++0x)
converts the given integral or floating point value to string
(function)
to_wstring (C++0x)
converts the given integral or floating point value to wstring
(function)

[edit] Hash support

The following specializations of class template hash are defined. These specializations provide hash support for default string types.

Defined in header <string>

template<> class hash<string>;
(C++0x feature)
template<> class hash<wstring>;
(C++0x feature)
template<> class hash<u16string>;
(C++0x feature)
template<> class hash<u32string>;
(C++0x feature)

[edit] char_traits

Strings library provides class template char_traits, defining types and functions for a character container. The following specializations are defined:

Defined in header <string>

template<> class char_traits<string>;

template<> class char_traits<wstring>;

template<> class char_traits<u16string>;
(C++0x feature)
template<> class char_traits<u32string>;
(C++0x feature)
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox
In other languages