diff --git a/libcxx/include/__functional/operations.h b/libcxx/include/__functional/operations.h index c0e719bb581b..7a80dce648fa 100644 --- a/libcxx/include/__functional/operations.h +++ b/libcxx/include/__functional/operations.h @@ -379,8 +379,8 @@ struct less { typedef void is_transparent; }; -template -struct __make_transparent<_Tp, less<_Tp> > { +template +struct __make_transparent<_ArgumentType, less<_ArgumentType> > { using type _LIBCPP_NODEBUG = less<>; }; @@ -477,8 +477,8 @@ struct greater { template inline const bool __desugars_to_v<__greater_tag, greater<>, _Tp, _Up> = true; -template -struct __make_transparent<_Tp, greater<_Tp>> { +template +struct __make_transparent<_ArgumentType, greater<_ArgumentType>> { using type _LIBCPP_NODEBUG = greater<>; }; diff --git a/libcxx/include/__type_traits/make_transparent.h b/libcxx/include/__type_traits/make_transparent.h index c2edf126d499..d3bca6684107 100644 --- a/libcxx/include/__type_traits/make_transparent.h +++ b/libcxx/include/__type_traits/make_transparent.h @@ -22,29 +22,30 @@ _LIBCPP_BEGIN_NAMESPACE_STD // __make_transparent tries to create a transparent comparator from its non-transparent counterpart, e.g. obtain // `less<>` from `less`. This is useful in cases where conversions can be avoided (e.g. a string literal to a -// std::string). +// std::string). This depends on the argument type provided to the comparator, because a comparator might be +// transparent for some argument types but not for others. -template +template struct __make_transparent { using type _LIBCPP_NODEBUG = _Comparator; }; -template -using __make_transparent_t _LIBCPP_NODEBUG = typename __make_transparent<_Tp, _Comparator>::type; +template +using __make_transparent_t _LIBCPP_NODEBUG = typename __make_transparent<_ArgumentType, _Comparator>::type; -template >::value, int> = 0> + __enable_if_t >::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _Comparator& __as_transparent(_Comparator& __comp) { return __comp; } -template >::value, int> = 0> -_LIBCPP_HIDE_FROM_ABI __make_transparent_t<_Tp, _Comparator> __as_transparent(_Comparator&) { + __enable_if_t >::value, int> = 0> +_LIBCPP_HIDE_FROM_ABI __make_transparent_t<_ArgumentType, _Comparator> __as_transparent(_Comparator&) { static_assert(is_empty<_Comparator>::value); - return __make_transparent_t<_Tp, _Comparator>(); + return __make_transparent_t<_ArgumentType, _Comparator>(); } _LIBCPP_END_NAMESPACE_STD