diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index b0675e1ad1b0..33124d2e21db 100644 --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -959,34 +959,15 @@ template _LIBCPP_CONSTEXPR bool is_compound_v // __is_referenceable [defns.referenceable] -template struct __is_referenceable - : public std::integral_constant::value || is_reference<_Tp>::value> {}; -#ifndef _LIBCPP_HAS_NO_VARIADICS -template -struct __is_referenceable<_Ret(_Args...)> : public std::true_type {}; +struct __is_referenceable_impl { + template static _Tp& __test(int); + template static __two __test(...); +}; -template -struct __is_referenceable<_Ret(_Args..., ...)> : public std::true_type {}; -#else -template -struct __is_referenceable<_Ret()> : public std::true_type {}; -template -struct __is_referenceable<_Ret(_A0)> : public std::true_type {}; -template -struct __is_referenceable<_Ret(_A0, _A1)> : public std::true_type {}; -template -struct __is_referenceable<_Ret(_A0, _A1, _A2)> : public std::true_type {}; - -template -struct __is_referenceable<_Ret(...)> : public std::true_type {}; -template -struct __is_referenceable<_Ret(_A0, ...)> : public std::true_type {}; -template -struct __is_referenceable<_Ret(_A0, _A1, ...)> : public std::true_type {}; -template -struct __is_referenceable<_Ret(_A0, _A1, _A2, ...)> : public std::true_type {}; -#endif +template +struct __is_referenceable : std::integral_constant(0)), __two>::value> {}; // add_const diff --git a/libcxx/test/libcxx/utilities/meta/is_referenceable.pass.cpp b/libcxx/test/libcxx/utilities/meta/is_referenceable.pass.cpp index f42011d954fa..dd31ab5a33d0 100644 --- a/libcxx/test/libcxx/utilities/meta/is_referenceable.pass.cpp +++ b/libcxx/test/libcxx/utilities/meta/is_referenceable.pass.cpp @@ -39,6 +39,11 @@ static_assert(( std::__is_referenceable::value), ""); static_assert(( std::__is_referenceable::value), ""); #endif +static_assert(( std::__is_referenceable::value), ""); +static_assert(( std::__is_referenceable::value), ""); +static_assert(( std::__is_referenceable::value), ""); +static_assert(( std::__is_referenceable::value), ""); + // Functions without cv-qualifiers are referenceable static_assert(( std::__is_referenceable::value), ""); #if TEST_STD_VER >= 11