class template
<string>

std::basic_string

template < class charT,
           class traits = char_traits<charT>,    // basic_string::traits_type
           class Alloc = allocator<charT>        // basic_string::allocator_type
           > class basic_string;
Generic string class
The basic_string is the generalization of class string for any character type (see string for a description).

Template parameters

charT
Character type.
The string is formed by a sequence of characters of this type.
This shall be a non-array POD type.
traits
Character traits class that defines essential properties of the characters used by basic_string objects (see char_traits).
traits::char_type shall be the same as charT.
Aliased as member type basic_string::traits_type.
Alloc
Type of the allocator object used to define the storage allocation model. By default, the allocator class template is used, which defines the simplest memory allocation model and is value-independent.
Aliased as member type basic_string::allocator_type.

Note: Because the first template parameter is not aliased as any member type, charT is used throughout this reference to refer to this type.

Template instantiations


Member types

member typedefinitionnotes
traits_typeThe second template parameter (traits)defaults to: char_traits<charT>
allocator_typeThe third template parameter (Alloc)defaults to: allocator<charT>
value_typetraits_type::char_typeshall be the same as charT
referenceallocator_type::referencefor the default allocator: charT&
const_referenceallocator_type::const_referencefor the default allocator: const charT&
pointerallocator_type::pointerfor the default allocator: charT*
const_pointerallocator_type::const_pointerfor the default allocator: const charT*
iteratora random access iterator to charTconvertible to const_iterator
const_iteratora random access iterator to const charT
reverse_iteratorreverse_iterator<iterator>
const_reverse_iteratorreverse_iterator<const_iterator>
difference_typeallocator_type::difference_typeusually the same as ptrdiff_t
size_typeallocator_type::difference_typeusually the same as size_t
member typedefinitionnotes
traits_typeThe second template parameter (traits)defaults to: char_traits<charT>
allocator_typeThe third template parameter (Alloc)defaults to: allocator<charT>
value_typetraits_type::char_typeshall be the same as charT
referencevalue_type&
const_referenceconst value_type&
pointerallocator_traits<allocator_type>::pointerfor the default allocator: charT*
const_pointerallocator_traits<allocator_type>::const_pointerfor the default allocator: const charT*
iteratora random access iterator to charTconvertible to const_iterator
const_iteratora random access iterator to const charT
reverse_iteratorreverse_iterator<iterator>
const_reverse_iteratorreverse_iterator<const_iterator>
difference_typeallocator_traits<allocator_type>::difference_typeusually the same as ptrdiff_t
size_typeallocator_traits<allocator_type>::difference_typeusually the same as size_t

Member functions


Iterators:

Capacity:

Element access:

Modifiers:

String operations:

Non-member function overloads


Member constants