[char.traits.specializations] (original) (raw)

27 Strings library [strings]

27.2 Character traits [char.traits]

27.2.4 char_traits specializations [char.traits.specializations]

27.2.4.1 General [char.traits.specializations.general]

namespace std { template<> struct char_traits<char>;template<> struct char_traits<char8_t>;template<> struct char_traits<char16_t>;template<> struct char_traits<char32_t>;template<> struct char_traits<wchar_t>;}

The header defines five specializations of the class templatechar_traits:char_traits<​char>,char_traits<char8_t>,char_traits<char16_t>,char_traits<char32_t>, andchar_traits<wchar_t>.

27.2.4.2 struct char_traits [char.traits.specializations.char]

namespace std { template<> struct char_traits<char> { using char_type = char;using int_type = int;using off_type = streamoff;using pos_type = streampos;using state_type = mbstate_t;using comparison_category = strong_ordering;static constexpr void assign(char_type& c1, const char_type& c2) noexcept;static constexpr bool eq(char_type c1, char_type c2) noexcept;static constexpr bool lt(char_type c1, char_type c2) noexcept;static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);static constexpr size_t length(const char_type* s);static constexpr const char_type* find(const char_type* s, size_t n,const char_type& a);static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);static constexpr char_type* assign(char_type* s, size_t n, char_type a);static constexpr int_type not_eof(int_type c) noexcept;static constexpr char_type to_char_type(int_type c) noexcept;static constexpr int_type to_int_type(char_type c) noexcept;static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;static constexpr int_type eof() noexcept;};}

The type mbstate_t is defined in and can represent any of the conversion states that can occur in animplementation-defined set of supported multibyte character encoding rules.

The two-argument member assign is defined identically to the built-in operator =.

The two-argument members eqand lt are defined identically to the built-in operators== and < for type unsigned char.

The membereof()returnsEOF.

27.2.4.3 struct char_traits<char8_t> [char.traits.specializations.char8.t]

namespace std { template<> struct char_traits<char8_t> { using char_type = char8_t;using int_type = unsigned int;using off_type = streamoff;using pos_type = u8streampos;using state_type = mbstate_t;using comparison_category = strong_ordering;static constexpr void assign(char_type& c1, const char_type& c2) noexcept;static constexpr bool eq(char_type c1, char_type c2) noexcept;static constexpr bool lt(char_type c1, char_type c2) noexcept;static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);static constexpr size_t length(const char_type* s);static constexpr const char_type* find(const char_type* s, size_t n,const char_type& a);static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);static constexpr char_type* assign(char_type* s, size_t n, char_type a);static constexpr int_type not_eof(int_type c) noexcept;static constexpr char_type to_char_type(int_type c) noexcept;static constexpr int_type to_int_type(char_type c) noexcept;static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;static constexpr int_type eof() noexcept;};}

The two-argument members assign, eq, and ltare defined identically to the built-in operators =, ==, and < respectively.

The member eof() returns animplementation-defined constant that cannot appear as a valid UTF-8 code unit.

27.2.4.4 struct char_traits<char16_t> [char.traits.specializations.char16.t]

namespace std { template<> struct char_traits<char16_t> { using char_type = char16_t;using int_type = uint_least16_t;using off_type = streamoff;using pos_type = u16streampos;using state_type = mbstate_t;using comparison_category = strong_ordering;static constexpr void assign(char_type& c1, const char_type& c2) noexcept;static constexpr bool eq(char_type c1, char_type c2) noexcept;static constexpr bool lt(char_type c1, char_type c2) noexcept;static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);static constexpr size_t length(const char_type* s);static constexpr const char_type* find(const char_type* s, size_t n,const char_type& a);static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);static constexpr char_type* assign(char_type* s, size_t n, char_type a);static constexpr int_type not_eof(int_type c) noexcept;static constexpr char_type to_char_type(int_type c) noexcept;static constexpr int_type to_int_type(char_type c) noexcept;static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;static constexpr int_type eof() noexcept;};}

The two-argument members assign,eq, and lt are defined identically to the built-in operators =, ==, and<, respectively.

The member eof() returns animplementation-defined constant that cannot appear as a valid UTF-16 code unit.

27.2.4.5 struct char_traits<char32_t> [char.traits.specializations.char32.t]

namespace std { template<> struct char_traits<char32_t> { using char_type = char32_t;using int_type = uint_least32_t;using off_type = streamoff;using pos_type = u32streampos;using state_type = mbstate_t;using comparison_category = strong_ordering;static constexpr void assign(char_type& c1, const char_type& c2) noexcept;static constexpr bool eq(char_type c1, char_type c2) noexcept;static constexpr bool lt(char_type c1, char_type c2) noexcept;static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);static constexpr size_t length(const char_type* s);static constexpr const char_type* find(const char_type* s, size_t n,const char_type& a);static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);static constexpr char_type* assign(char_type* s, size_t n, char_type a);static constexpr int_type not_eof(int_type c) noexcept;static constexpr char_type to_char_type(int_type c) noexcept;static constexpr int_type to_int_type(char_type c) noexcept;static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;static constexpr int_type eof() noexcept;};}

The two-argument members assign,eq, and lt are defined identically to the built-in operators =, ==, and<, respectively.

The member eof() returns animplementation-defined constant that cannot appear as a Unicode code point.

27.2.4.6 struct char_traits<wchar_t> [char.traits.specializations.wchar.t]

namespace std { template<> struct char_traits<wchar_t> { using char_type = wchar_t;using int_type = wint_t;using off_type = streamoff;using pos_type = wstreampos;using state_type = mbstate_t;using comparison_category = strong_ordering;static constexpr void assign(char_type& c1, const char_type& c2) noexcept;static constexpr bool eq(char_type c1, char_type c2) noexcept;static constexpr bool lt(char_type c1, char_type c2) noexcept;static constexpr int compare(const char_type* s1, const char_type* s2, size_t n);static constexpr size_t length(const char_type* s);static constexpr const char_type* find(const char_type* s, size_t n,const char_type& a);static constexpr char_type* move(char_type* s1, const char_type* s2, size_t n);static constexpr char_type* copy(char_type* s1, const char_type* s2, size_t n);static constexpr char_type* assign(char_type* s, size_t n, char_type a);static constexpr int_type not_eof(int_type c) noexcept;static constexpr char_type to_char_type(int_type c) noexcept;static constexpr int_type to_int_type(char_type c) noexcept;static constexpr bool eq_int_type(int_type c1, int_type c2) noexcept;static constexpr int_type eof() noexcept;};}

The two-argument membersassign,eq, andltare defined identically to the built-in operators=,==, and<, respectively.

The membereof()returnsWEOF.