[libcxx] r261581 - 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.
Marshall Clow via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 22 14:13:03 PST 2016
Author: marshall
Date: Mon Feb 22 16:13:03 2016
New Revision: 261581
URL: http://llvm.org/viewvc/llvm-project?rev=261581&view=rev
Log:
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.
Modified:
libcxx/trunk/include/type_traits
libcxx/trunk/test/libcxx/utilities/meta/is_referenceable.pass.cpp
Modified: libcxx/trunk/include/type_traits
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/type_traits?rev=261581&r1=261580&r2=261581&view=diff
==============================================================================
--- libcxx/trunk/include/type_traits (original)
+++ libcxx/trunk/include/type_traits Mon Feb 22 16:13:03 2016
@@ -959,34 +959,15 @@ template <class _Tp> _LIBCPP_CONSTEXPR b
// __is_referenceable [defns.referenceable]
-template <class _Tp> struct __is_referenceable
- : public std::integral_constant<bool, is_object<_Tp>::value || is_reference<_Tp>::value> {};
-#ifndef _LIBCPP_HAS_NO_VARIADICS
-template <class _Ret, class... _Args>
-struct __is_referenceable<_Ret(_Args...)> : public std::true_type {};
-
-template <class _Ret, class... _Args>
-struct __is_referenceable<_Ret(_Args..., ...)> : public std::true_type {};
-#else
-template <class _Ret>
-struct __is_referenceable<_Ret()> : public std::true_type {};
-template <class _Ret, class _A0>
-struct __is_referenceable<_Ret(_A0)> : public std::true_type {};
-template <class _Ret, class _A0, class _A1>
-struct __is_referenceable<_Ret(_A0, _A1)> : public std::true_type {};
-template <class _Ret, class _A0, class _A1, class _A2>
-struct __is_referenceable<_Ret(_A0, _A1, _A2)> : public std::true_type {};
-
-template <class _Ret>
-struct __is_referenceable<_Ret(...)> : public std::true_type {};
-template <class _Ret, class _A0>
-struct __is_referenceable<_Ret(_A0, ...)> : public std::true_type {};
-template <class _Ret, class _A0, class _A1>
-struct __is_referenceable<_Ret(_A0, _A1, ...)> : public std::true_type {};
-template <class _Ret, class _A0, class _A1, class _A2>
-struct __is_referenceable<_Ret(_A0, _A1, _A2, ...)> : public std::true_type {};
-#endif
+struct __is_referenceable_impl {
+ template <class _Tp> static _Tp& __test(int);
+ template <class _Tp> static __two __test(...);
+};
+
+template <class _Tp>
+struct __is_referenceable : std::integral_constant<bool,
+ !std::is_same<decltype(__is_referenceable_impl::__test<_Tp>(0)), __two>::value> {};
// add_const
Modified: libcxx/trunk/test/libcxx/utilities/meta/is_referenceable.pass.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/libcxx/utilities/meta/is_referenceable.pass.cpp?rev=261581&r1=261580&r2=261581&view=diff
==============================================================================
--- libcxx/trunk/test/libcxx/utilities/meta/is_referenceable.pass.cpp (original)
+++ libcxx/trunk/test/libcxx/utilities/meta/is_referenceable.pass.cpp Mon Feb 22 16:13:03 2016
@@ -39,6 +39,11 @@ static_assert(( std::__is_referenceable<
static_assert(( std::__is_referenceable<const Foo &&>::value), "");
#endif
+static_assert(( std::__is_referenceable<int __attribute__((__vector_size__( 8)))>::value), "");
+static_assert(( std::__is_referenceable<const int __attribute__((__vector_size__( 8)))>::value), "");
+static_assert(( std::__is_referenceable<float __attribute__((__vector_size__(16)))>::value), "");
+static_assert(( std::__is_referenceable<const float __attribute__((__vector_size__(16)))>::value), "");
+
// Functions without cv-qualifiers are referenceable
static_assert(( std::__is_referenceable<void ()>::value), "");
#if TEST_STD_VER >= 11
More information about the cfe-commits
mailing list