(original) (raw)
class template
std::char_traits
template struct char_traits;template <> struct char_traits;template <> struct char_traits;
template struct char_traits;template <> struct char_traits;template <> struct char_traits;template <> struct char_traits;template <> struct char_traits;
Character traits
Character traits classes specify character properties and provide specific semantics for certain operations on characters and sequences of characters.
The standard library includes a standard set of character traits classes that can be instantiated from the
char_traits template, and which are used by default both for the basic_string objects and for the input/output stream objects. But any other class that follows the requirements of a character traits class can be used instead. This reference attempts to describe both the definition of the standard char_traits and the requirements for custom character traits classes.
Template parameters
charT
Character type.
The class defines the standard character traits for this character type.
This shall be one of the types for which an specialization is provided.
Aliased as member type char_traits::char_type.
Template specializations
The char_traits standard template supports to be instantiated with at least the following character types:
type | Description |
---|---|
char | Basic character set (size of 1 byte) |
wchar_t | Wide character set (same size, signedness, and alignment as another integral type) |
char | Basic character set (size of 1 byte) |
---|---|
wchar_t | Widest character set (same size, signedness, and alignment as another integral type) |
char16_t | Represents 16-bit code units (same size, signedness, and alignment as uint_least16_t) |
char32_t | Represents any of the 32-bit code points (same size, signedness, and alignment as uint_least32_t) |
Member types
member type | description for character traits types | definition | |
---|---|---|---|
char | wchar_t | ||
char_type | The template parameter (charT) | char | wchar_t |
int_type | Integral type that can represent all charT values, as well as eof() | int | wint_t |
off_type | A type that behaves like streamoff | streamoff | streamoff |
pos_type | A type that behaves like streampos | streampos | wstreampos |
state_type | Multibyte transformation state type, such as mbstate_t | mbstate_t | mbstate_t |
member type | description for character traits types | definition | |||
---|---|---|---|---|---|
char | wchar_t | char16_t | char32_t | ||
char_type | The template parameter (charT) | char | wchar_t | char16_t | char32_t |
int_type | Integral type that can represent all charT values, as well as eof() | int | wint_t | uint_least16_t | uint_least32_t |
off_type | A type that behaves like streamoff | streamoff | streamoff | streamoff | streamoff |
pos_type | A type that behaves like streampos | streampos | wstreampos | u16streampos | u32streampos |
state_type | Multibyte transformation state type, such as mbstate_t | mbstate_t | mbstate_t | mbstate_t | mbstate_t |
Member functions
Compare characters for equality (public static member function)
Compare characters for inequality (public static member function)
Get length of null-terminated string (public static member function)
Assign character (public static member function)
Compare sequences of characters (public static member function)
Find first occurrence of character (public static member function)
Move character sequence (public static member function)
Copy character sequence (public static member function)
End-of-File character (public static member function)
Not End-of-File character (public static member function)
To char type (public static member function)
To int type (public static member function)
Compare int_type values (public static member function)