From 9b4880e7ecafafcbd8ca749f5985df31340e075f Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 22 Feb 2016 22:13:03 +0000 Subject: [PATCH] Fix __is_referenceable to work with vector types. Fixes PR#26654 and 26656. Thanks to Evgeniy for the reports, and to Eric for the suggestion on how to fix it. llvm-svn: 261581 --- libcxx/include/type_traits | 33 +++++----------------- .../utilities/meta/is_referenceable.pass.cpp | 5 ++++ 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits index b0675e1a..33124d2 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 f42011d..dd31ab5 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 -- 2.7.4