The char_traits class is a traits class template that abstracts basic character and string operations for a given character type. The defined operation set is such that generic algorithms almost always can be implemented in terms of it. It is thus possible to use such algorithms with almost any possible character or string type, just by supplying customized char_traits class.

The char_traits class template serves as a basis for explicit instantiations. The user can provide a specialization for any custom character types. Several specializations are defined for the standard character types. The values of the member typedefs are as follows.

Instantiation

char_type

int_type

off_type

pos_type

state_type

char_traits<char>

char

int

std::streamoff

std::streampos

std::mbstate_t

char_traits<wchar_t>

wchar_t

std::wint_t

std::wstreamoff

std::wstreampos

std::mbstate_t

char_traits<char16_t>(C++11)

char16_t

std::uint_least16_t

std::streamoff

std::u16streampos

std::mbstate_t

char_traits<char32_t>(C++11)

char32_t

std::uint_least32_t

std::streamoff

std::u32streampos

std::mbstate_t

The char_traits class template satisfies the requirements of CharTraits.

This section is incompleteReason: simplify the description, emphasize that char_traits can be user defined