Namespaces
Variants

std::char_traits

From cppreference.com
Defined in header <string>
template<
    class CharT 
> class char_traits;

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 a 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 explicit specializations are provided for the standard character types (see below), other specializations are not required to satisfy the requirements of CharTraits.

Specializations

The standard library provides the following standard specializations:

Defined in header <string>
std::char_traits<char> the standard character traits of char
std::char_traits<wchar_t> the standard character traits of wchar_t
std::char_traits<char8_t> (C++20) the standard character traits of char8_t
std::char_traits<char16_t> (C++11) the standard character traits of char16_t
std::char_traits<char32_t> (C++11) the standard character traits of char32_t

All these specializations satisfy the requirements of CharTraits.

Member types

The standard specializations define the following member types required by CharTraits:

CharT Member type
 char_type  int_type off_type pos_type state_type
char char int  std::streamoff  std::streampos  std::mbstate_t 
wchar_t wchar_t std::wint_t std::wstreampos
char8_t char8_t unsigned int std::u8streampos
 char16_t  char16_t