Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/string"

From cppreference.com
< cpp
(fix link)
m (Text replace - "typename" to "class")
Line 12: Line 12:
 
{{ddcl | header=string | 1=
 
{{ddcl | header=string | 1=
 
template<  
 
template<  
     typename CharT,  
+
     class CharT,  
     typename Traits = std::char_traits<CharT>,  
+
     class Traits = std::char_traits<CharT>,  
     typename Allocator = std::allocator<CharT> >
+
     class Allocator = std::allocator<CharT> >
 
> class basic_string;
 
> class basic_string;
 
}}
 
}}

Revision as of 08:18, 18 December 2011

Template:cpp/string/sidebar

Contents

Null-terminated byte string management

Null-terminated multibyte string management

Null-terminated wide string management

basic_string

Defined in header <string>
template<

    class CharT,
    class Traits = std::char_traits<CharT>,
    class Allocator = std::allocator<CharT> >

> class basic_string;

The class basic_string generalizes the way how sequences of characters are manipulated and stored.

Several specializations of the class basic_string are provided:

Template:tdcl list begin Template:tdcl list header Template:tdcl list hitem Template:tdcl list item Template:tdcl list item Template:tdcl list item Template:tdcl list item Template:tdcl list end

Hash support

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

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <string>
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td >
template<> class hash<std::string>;

template<> class hash<std::wstring>;
template<> class hash<std::u16string>;

template<> class hash<std::u32string>;
</td>

<td class="t-dcl-nopad"> </td> <td > Template:mark c++11 feature
Template:mark c++11 feature
Template:mark c++11 feature
Template:mark c++11 feature </td> </tr> Template:ddcl list end

char_traits

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

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <string>
</td>

<td></td> <td></td> </tr> <tr class="t-dcl ">

<td >
template<> class char_traits<std::string>;

template<> class char_traits<std::wstring>;
template<> class char_traits<std::u16string>;

template<> class char_traits<std::u32string>;
</td>

<td class="t-dcl-nopad"> </td> <td >

Template:mark c++11 feature
Template:mark c++11 feature </td> </tr> Template:ddcl list end