diff --git a/libcxx/include/__tree b/libcxx/include/__tree index 2c059a92473c7..bb8c4f3f8c623 100644 --- a/libcxx/include/__tree +++ b/libcxx/include/__tree @@ -1881,9 +1881,9 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const _Key& __v) { } __node_base_pointer* __node_ptr = __root_ptr(); - auto&& __transparent = std::__as_transparent<_Key>(value_comp()); + auto&& __transparent = std::__as_transparent(value_comp()); auto __comp = - __lazy_synth_three_way_comparator<__make_transparent_t<_Key, _Compare>, _Key, value_type>(__transparent); + __lazy_synth_three_way_comparator<__make_transparent_t, _Key, value_type>(__transparent); while (true) { auto __comp_res = __comp(__v, __nd->__get_value()); diff --git a/libcxx/include/string b/libcxx/include/string index c59684c32a3fe..fc14e27787944 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -625,6 +625,7 @@ basic_string operator""s( const char32_t *str, size_t len ); # include <__string/char_traits.h> # include <__string/extern_template_lists.h> # include <__type_traits/conditional.h> +# include <__type_traits/desugars_to.h> # include <__type_traits/enable_if.h> # include <__type_traits/is_allocator.h> # include <__type_traits/is_array.h> @@ -2602,19 +2603,29 @@ struct __default_three_way_comparator, bas }; # endif -template -inline const bool __is_transparently_comparable_v<_Comparator, - basic_string<_CharT, _Traits, _Alloc>, - const _CharT*, - __enable_if_t<__is_generic_transparent_comparator_v<_Comparator> > > = - true; +template +inline const bool __is_transparently_comparable_v<_Comparator, basic_string<_CharT, _Traits, _Alloc>, _CharT2*> = + is_same<_CharT, __remove_cv_t<_CharT2> >::value && + (__desugars_to_v<__less_tag, + _Comparator, + basic_string<_CharT, _Traits, _Alloc>, + basic_string<_CharT, _Traits, _Alloc> > || + __desugars_to_v<__greater_tag, + _Comparator, + basic_string<_CharT, _Traits, _Alloc>, + basic_string<_CharT, _Traits, _Alloc> >); + +template +inline const bool __is_transparently_comparable_v<_Comparator, _CharT2*, basic_string<_CharT, _Traits, _Alloc> > = + __is_transparently_comparable_v<_Comparator, basic_string<_CharT, _Traits, _Alloc>, _CharT2*>; template -inline const bool __is_transparently_comparable_v<_Comparator, - basic_string<_CharT, _Traits, _Alloc>, - _CharT[_Np], - __enable_if_t<__is_generic_transparent_comparator_v<_Comparator> > > = - true; +inline const bool __is_transparently_comparable_v<_Comparator, basic_string<_CharT, _Traits, _Alloc>, _CharT[_Np]> = + __is_transparently_comparable_v<_Comparator, basic_string<_CharT, _Traits, _Alloc>, const _CharT*>; + +template +inline const bool __is_transparently_comparable_v<_Comparator, _CharT[_Np], basic_string<_CharT, _Traits, _Alloc> > = + __is_transparently_comparable_v<_Comparator, basic_string<_CharT, _Traits, _Alloc>, const _CharT*>; # if _LIBCPP_STD_VER >= 17 template +#include +#include <__type_traits/desugars_to.h> + +static_assert(std::__is_transparently_comparable_v, std::string, const char*>, ""); +static_assert(std::__is_transparently_comparable_v, std::string, char*>, ""); +static_assert(std::__is_transparently_comparable_v, std::string, char[5]>, ""); + +static_assert(std::__is_transparently_comparable_v, const char*, std::string>, ""); +static_assert(std::__is_transparently_comparable_v, char*, std::string>, ""); +static_assert(std::__is_transparently_comparable_v, char[5], std::string>, ""); + +static_assert( + !std::__is_transparently_comparable_v >, std::string, char[5]>, ""); +static_assert( + !std::__is_transparently_comparable_v >, char[5], std::string>, ""); +static_assert( + !std::__is_transparently_comparable_v >, std::string, char const*>, + ""); +static_assert( + !std::__is_transparently_comparable_v >, char const*, std::string>, + "");