diff --git a/libcxx/include/__functional/weak_result_type.h b/libcxx/include/__functional/weak_result_type.h --- a/libcxx/include/__functional/weak_result_type.h +++ b/libcxx/include/__functional/weak_result_type.h @@ -25,11 +25,10 @@ struct __has_result_type { private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::result_type* = 0); + template static false_type __test(...); + template static true_type __test(typename _Up::result_type* = 0); public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; + static const bool value = decltype(__test<_Tp>(0))::value; }; // __weak_result_type diff --git a/libcxx/include/__iterator/iterator_traits.h b/libcxx/include/__iterator/iterator_traits.h --- a/libcxx/include/__iterator/iterator_traits.h +++ b/libcxx/include/__iterator/iterator_traits.h @@ -105,15 +105,14 @@ struct __has_iterator_typedefs { private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename __void_t::type* = 0, - typename __void_t::type* = 0, - typename __void_t::type* = 0, - typename __void_t::type* = 0, - typename __void_t::type* = 0); + template static false_type __test(...); + template static true_type __test(typename __void_t::type* = 0, + typename __void_t::type* = 0, + typename __void_t::type* = 0, + typename __void_t::type* = 0, + typename __void_t::type* = 0); public: - static const bool value = sizeof(__test<_Tp>(0,0,0,0,0)) == 1; + static const bool value = decltype(__test<_Tp>(0,0,0,0,0))::value; }; @@ -121,22 +120,20 @@ struct __has_iterator_category { private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::iterator_category* = nullptr); + template static false_type __test(...); + template static true_type __test(typename _Up::iterator_category* = nullptr); public: - static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; + static const bool value = decltype(__test<_Tp>(nullptr))::value; }; template struct __has_iterator_concept { private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::iterator_concept* = nullptr); + template static false_type __test(...); + template static true_type __test(typename _Up::iterator_concept* = nullptr); public: - static const bool value = sizeof(__test<_Tp>(nullptr)) == 1; + static const bool value = decltype(__test<_Tp>(nullptr))::value; }; #if _LIBCPP_STD_VER > 17 diff --git a/libcxx/include/__memory/pointer_traits.h b/libcxx/include/__memory/pointer_traits.h --- a/libcxx/include/__memory/pointer_traits.h +++ b/libcxx/include/__memory/pointer_traits.h @@ -71,13 +71,12 @@ struct __has_rebind { private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); + template static false_type __test(...); _LIBCPP_SUPPRESS_DEPRECATED_PUSH - template static char __test(typename _Xp::template rebind<_Up>* = 0); + template static true_type __test(typename _Xp::template rebind<_Up>* = 0); _LIBCPP_SUPPRESS_DEPRECATED_POP public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; + static const bool value = decltype(__test<_Tp>(0))::value; }; template ::value> diff --git a/libcxx/include/__memory/uses_allocator.h b/libcxx/include/__memory/uses_allocator.h --- a/libcxx/include/__memory/uses_allocator.h +++ b/libcxx/include/__memory/uses_allocator.h @@ -24,11 +24,10 @@ struct __has_allocator_type { private: - struct __two {char __lx; char __lxx;}; - template static __two __test(...); - template static char __test(typename _Up::allocator_type* = 0); + template static false_type __test(...); + template static true_type __test(typename _Up::allocator_type* = 0); public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; + static const bool value = decltype(__test<_Tp>(0))::value; }; template ::value> diff --git a/libcxx/include/__type_traits/is_class.h b/libcxx/include/__type_traits/is_class.h --- a/libcxx/include/__type_traits/is_class.h +++ b/libcxx/include/__type_traits/is_class.h @@ -29,12 +29,12 @@ namespace __is_class_imp { -template char __test(int _Tp::*); -template __two __test(...); +template true_type __test(int _Tp::*); +template false_type __test(...); } template struct _LIBCPP_TEMPLATE_VIS is_class - : public integral_constant(0)) == 1 && !is_union<_Tp>::value> {}; + : public integral_constant(0))::value && !is_union<_Tp>::value> {}; #endif diff --git a/libcxx/include/__type_traits/is_polymorphic.h b/libcxx/include/__type_traits/is_polymorphic.h --- a/libcxx/include/__type_traits/is_polymorphic.h +++ b/libcxx/include/__type_traits/is_polymorphic.h @@ -18,27 +18,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if __has_feature(is_polymorphic) || defined(_LIBCPP_COMPILER_MSVC) - template struct _LIBCPP_TEMPLATE_VIS is_polymorphic : public integral_constant {}; -#else - -template char &__is_polymorphic_impl( - typename enable_if(declval<_Tp*>())) != 0, - int>::type); -template __two &__is_polymorphic_impl(...); - -template struct _LIBCPP_TEMPLATE_VIS is_polymorphic - : public integral_constant(0)) == 1> {}; - -#endif // __has_feature(is_polymorphic) - #if _LIBCPP_STD_VER > 14 template -inline constexpr bool is_polymorphic_v = is_polymorphic<_Tp>::value; +inline constexpr bool is_polymorphic_v = __is_polymorphic(_Tp); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_referenceable.h b/libcxx/include/__type_traits/is_referenceable.h --- a/libcxx/include/__type_traits/is_referenceable.h +++ b/libcxx/include/__type_traits/is_referenceable.h @@ -19,16 +19,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD -struct __two {char __lx[2];}; - struct __is_referenceable_impl { template static _Tp& __test(int); - template static __two __test(...); + template static false_type __test(...); }; template struct __is_referenceable : integral_constant(0)), __two>::value> {}; + _IsNotSame(0)), false_type>::value> {}; _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -1353,14 +1353,14 @@ template struct __is_destructor_wellformed { template - static char __test ( + static true_type __test ( typename __is_destructible_apply().~_Tp1())>::type ); template - static __two __test (...); + static false_type __test (...); - static const bool value = sizeof(__test<_Tp>(12)) == sizeof(char); + static const bool value = decltype(__test<_Tp>(12))::value; }; template