std::char_traits
From cppreference.com
                    
                                        
                    
                    
                                                            
                    |   Defined in header <string>
   | 
||
|   template<     class CharT   | 
||
The char_traits class defines the stream and string operation properties of a character type, such as the types used for manipulating the characters and character strings, as well as all the common operations for the given character type.
| This section is incomplete Reason: simplify the description, emphasize that char_traits can be user defined  | 
[edit] Member types
| Type | Definition | 
| char_type | CharT | 
| int_type | an integer type that can hold all values of char_type plus EOF | 
| off_type | implementation-defined | 
| pos_type | implementation-defined | 
| state_type | implementation-defined | 
[edit] Member functions
| Signature | Effects / Return value | Complexity | 
|---|---|---|
| void assign(CharT &r, CharT a) noexcept | assigns r = a | constant | 
| constexpr bool eq(CharT a, CharT b) noexcept | shall return true if a and b are equivalent | constant | 
| constexpr bool lt( CharT a, CharT b ) noexcept | shall return true if a is less than b | constant | 
| char_type *assign(CharT *p, size_t n, CharT a) | shall assign value a to character string [p, p+n). Shall return p | linear | 
| char_type *move(CharT *p, const CharT *q, size_t n) |  shall assign character string [q, q+n) to character string [p, p+n). Shall return p. Performs correctly even if [p, p+n) and [q, q+n) overlap.  | 
linear | 
| char_type *copy(CharT *p, const CharT *q, size_t n) |  shall assign character string [q, q+n) to character string [p, p+n). Shall return p. q shall not be in [p, p+n)  | 
linear | 
| int compare(const CharT *p, const CharT *q, size_t n) |  shall return 0 if character strings [p, p+n) and [q, q+n) are equal, shall return negative value if [p, p+n) is less than [q, q+n) and shall return positive value if [p, p+n) is greater than [q, q+n). The comparison is done lexicographically, using eq and lt functions.  | 
linear | 
| size_t length(const char_type* s) | shall return the position of the terminating Char() (i.e. null-character) | linear | 
| const char_type *find(const CharT *p, size_t n, CharT a) | shall return the pointer to the first character of value a in character string p | linear | 
| constexpr char_type to_char_type(int_type a) noexcept |  shall return equivalent value of char_type type. If there is no such value, return value is unspecified  | 
constant | 
| constexpr int_type to_int_type(char_type a) noexcept | shall return equivalent value of int_type type. | constant | 
| constexpr bool eq_int_type(int_type a, int_type b) noexcept |  shall return false if one of a or b equals eof() and the other is not.  Shall return true if a equals b. Return value is unspecified in other cases.  | 
constant | 
| constexpr int_type eof() noexcept | shall return a value not equal to any value of type char_type | constant | 
| constexpr bool not_eof(int_type a) noexcept | shall return false if a and eof() are equivalent | constant | 
(constexpr and noexcept specification were added in C++11)
There is class template char_traits defined, which serves as a basis for explicit instantiations. It fulfills all requirements of Traits concept.
Also, several specializations are defined for most common character types which which has to specify the following members:
| Instantiation | char_type | int_type | off_type | pos_type | state_type | 
|---|---|---|---|---|---|
| char_traits<char> | char | int | streamoff | streampos | mbstate_t | 
| char_traits<wchar_t> | wchar_t | wint_t | wstreamoff | wstreampos | mbstate_t | 
| char_traits<char16_t> (C++11) | char16_t | int_least16_t | streamoff | u16streampos | mbstate_t | 
| char_traits<char32_t> (C++11) | char32_t | int_least32_t | streamoff | u32streampos | mbstate_t | 
[edit] See also
|    stores and manipulates sequences of characters  (class template)  | |