C++ named requirements: CharTraits

CharTraits is a traits class that abstracts basic character and string operations for a given character type. Most standard library string and input/output classes require a CharTraits template type parameter alongside a corresponding character template type parameter.

# Declarations

template<> class char_traits<char>;
template<> class char_traits<wchar_t>;
template<> class char_traits<char8_t>;
template<> class char_traits<char16_t>;
template<> class char_traits<char32_t>;

(since C++20)(since C++11)(since C++11)

# Defect reports

DRApplied toBehavior as publishedCorrect behavior
LWG 335C++98the requirements on the binary overload ofassign did not prevent assignments to rvaluesits first argumentcan only be an lvalue
LWG 352C++98X::state_type was onlyrequired to be CopyConstructibleit is also required to beCopyAssignable and DefaultConstructible
LWG 3085C++98X::copy(s, p, n) only required p notin [s, s + n), which is too weak[1]requires [p, p + n) and[s, s + n) not to overlap