diff --git a/stl/inc/regex b/stl/inc/regex index 05cb7465d3b..7053b6173f8 100644 --- a/stl/inc/regex +++ b/stl/inc/regex @@ -178,6 +178,38 @@ struct _Cl_names { // structure to associate class name with mask value } }; +template +struct _Char_traits_eq { + using _Elem = typename _Traits::char_type; + + bool operator()(_Elem _Left, _Elem _Right) const noexcept { + return _Traits::eq(_Left, _Right); + } +}; + +template +struct _Char_traits_lt { + using _Elem = typename _Traits::char_type; + + bool operator()(_Elem _Left, _Elem _Right) const noexcept { + return _Traits::lt(_Left, _Right); + } +}; + +// library-provided char_traits::eq behaves like equal_to<_Elem> +// TRANSITION: This should not be activated for user-defined specializations of char_traits +template +_INLINE_VAR constexpr bool _Can_memcmp_elements_with_pred<_Elem, _Elem, _Char_traits_eq>> = + _Can_memcmp_elements<_Elem, _Elem>; + +// library-provided char_traits::lt behaves like less> +// TRANSITION: This should not be activated for user-defined specializations of char_traits +template +struct _Lex_compare_memcmp_classify_pred<_Elem, _Elem, _Char_traits_lt>> { + using _UElem = make_unsigned_t<_Elem>; + using _Pred = conditional_t<_Lex_compare_memcmp_classify_elements<_UElem, _UElem>, less, void>; +}; + template struct _Cmp_cs { // functor to compare two character values for equality using _Elem = typename _RxTraits::char_type; diff --git a/stl/inc/xstring b/stl/inc/xstring index 80453b0d412..aacda3476e5 100644 --- a/stl/inc/xstring +++ b/stl/inc/xstring @@ -535,38 +535,6 @@ basic_ostream<_Elem, _Traits>& _Insert_string( return _Ostr; } -template -struct _Char_traits_eq { - using _Elem = typename _Traits::char_type; - - bool operator()(_Elem _Left, _Elem _Right) const noexcept { - return _Traits::eq(_Left, _Right); - } -}; - -template -struct _Char_traits_lt { - using _Elem = typename _Traits::char_type; - - bool operator()(_Elem _Left, _Elem _Right) const noexcept { - return _Traits::lt(_Left, _Right); - } -}; - -// library-provided char_traits::eq behaves like equal_to<_Elem> -// TRANSITION: This should not be activated for user-defined specializations of char_traits -template -_INLINE_VAR constexpr bool _Can_memcmp_elements_with_pred<_Elem, _Elem, _Char_traits_eq>> = - _Can_memcmp_elements<_Elem, _Elem>; - -// library-provided char_traits::lt behaves like less> -// TRANSITION: This should not be activated for user-defined specializations of char_traits -template -struct _Lex_compare_memcmp_classify_pred<_Elem, _Elem, _Char_traits_lt>> { - using _UElem = make_unsigned_t<_Elem>; - using _Pred = conditional_t<_Lex_compare_memcmp_classify_elements<_UElem, _UElem>, less, void>; -}; - template using _Traits_ch_t = typename _Traits::char_type; diff --git a/tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp b/tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp index 7d1a69b6dd8..5159486e50b 100644 --- a/tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp +++ b/tests/std/tests/GH_000431_equal_memcmp_is_safe/test.compile.pass.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp b/tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp index 84aabcc3414..2d0e1b77179 100644 --- a/tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp +++ b/tests/std/tests/GH_000431_lex_compare_memcmp_classify/test.compile.pass.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include