diff --git a/libcxx/include/__type_traits/alignment_of.h b/libcxx/include/__type_traits/alignment_of.h --- a/libcxx/include/__type_traits/alignment_of.h +++ b/libcxx/include/__type_traits/alignment_of.h @@ -24,7 +24,7 @@ #if _LIBCPP_STD_VER > 14 template -inline constexpr size_t alignment_of_v = alignment_of<_Tp>::value; +inline constexpr size_t alignment_of_v = _LIBCPP_ALIGNOF(_Tp); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/apply_cv.h b/libcxx/include/__type_traits/apply_cv.h --- a/libcxx/include/__type_traits/apply_cv.h +++ b/libcxx/include/__type_traits/apply_cv.h @@ -10,7 +10,6 @@ #define _LIBCPP___TYPE_TRAITS_APPLY_CV_H #include <__config> -#include <__type_traits/integral_constant.h> #include <__type_traits/is_const.h> #include <__type_traits/is_volatile.h> #include <__type_traits/remove_reference.h> diff --git a/libcxx/include/__type_traits/decay.h b/libcxx/include/__type_traits/decay.h --- a/libcxx/include/__type_traits/decay.h +++ b/libcxx/include/__type_traits/decay.h @@ -12,7 +12,6 @@ #include <__config> #include <__type_traits/add_pointer.h> #include <__type_traits/conditional.h> -#include <__type_traits/integral_constant.h> #include <__type_traits/is_array.h> #include <__type_traits/is_function.h> #include <__type_traits/is_referenceable.h> diff --git a/libcxx/include/__type_traits/disjunction.h b/libcxx/include/__type_traits/disjunction.h --- a/libcxx/include/__type_traits/disjunction.h +++ b/libcxx/include/__type_traits/disjunction.h @@ -10,7 +10,6 @@ #define _LIBCPP___TYPE_TRAITS_DISJUNCTION_H #include <__config> -#include <__type_traits/conditional.h> #include <__type_traits/integral_constant.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) diff --git a/libcxx/include/__type_traits/has_virtual_destructor.h b/libcxx/include/__type_traits/has_virtual_destructor.h --- a/libcxx/include/__type_traits/has_virtual_destructor.h +++ b/libcxx/include/__type_traits/has_virtual_destructor.h @@ -18,21 +18,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if __has_builtin(__has_virtual_destructor) - template struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor : public integral_constant {}; -#else - -template struct _LIBCPP_TEMPLATE_VIS has_virtual_destructor - : public false_type {}; - -#endif - #if _LIBCPP_STD_VER > 14 template -inline constexpr bool has_virtual_destructor_v = has_virtual_destructor<_Tp>::value; +inline constexpr bool has_virtual_destructor_v = __has_virtual_destructor(_Tp); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_assignable.h b/libcxx/include/__type_traits/is_assignable.h --- a/libcxx/include/__type_traits/is_assignable.h +++ b/libcxx/include/__type_traits/is_assignable.h @@ -18,10 +18,6 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template struct __select_2nd { typedef _LIBCPP_NODEBUG _Tp type; }; - -#if __has_builtin(__is_assignable) - template struct _LIBCPP_TEMPLATE_VIS is_assignable : _BoolConstant<__is_assignable(_Tp, _Up)> { }; @@ -30,37 +26,6 @@ inline constexpr bool is_assignable_v = __is_assignable(_Tp, _Arg); #endif -#else // __has_builtin(__is_assignable) - -template -typename __select_2nd() = declval<_Arg>())), true_type>::type -__is_assignable_test(int); - -template -false_type __is_assignable_test(...); - - -template ::value || is_void<_Arg>::value> -struct __is_assignable_imp - : public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {}; - -template -struct __is_assignable_imp<_Tp, _Arg, true> - : public false_type -{ -}; - -template -struct is_assignable - : public __is_assignable_imp<_Tp, _Arg> {}; - -#if _LIBCPP_STD_VER > 14 -template -inline constexpr bool is_assignable_v = is_assignable<_Tp, _Arg>::value; -#endif - -#endif // __has_builtin(__is_assignable) - _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP___TYPE_TRAITS_IS_ASSIGNABLE_H 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 @@ -11,8 +11,6 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_union.h> -#include <__type_traits/remove_cv.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/is_constructible.h b/libcxx/include/__type_traits/is_constructible.h --- a/libcxx/include/__type_traits/is_constructible.h +++ b/libcxx/include/__type_traits/is_constructible.h @@ -25,7 +25,7 @@ #if _LIBCPP_STD_VER > 14 template -inline constexpr bool is_constructible_v = is_constructible<_Tp, _Args...>::value; +inline constexpr bool is_constructible_v = __is_constructible(_Tp, _Args...); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_copy_assignable.h b/libcxx/include/__type_traits/is_copy_assignable.h --- a/libcxx/include/__type_traits/is_copy_assignable.h +++ b/libcxx/include/__type_traits/is_copy_assignable.h @@ -13,7 +13,6 @@ #include <__type_traits/add_const.h> #include <__type_traits/add_lvalue_reference.h> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_assignable.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -21,9 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template struct _LIBCPP_TEMPLATE_VIS is_copy_assignable - : public is_assignable::type, - typename add_lvalue_reference::type>::type> {}; +template +struct _LIBCPP_TEMPLATE_VIS is_copy_assignable + : public integral_constant< + bool, + __is_assignable(typename add_lvalue_reference<_Tp>::type, + typename add_lvalue_reference::type>::type)> {}; #if _LIBCPP_STD_VER > 14 template diff --git a/libcxx/include/__type_traits/is_copy_constructible.h b/libcxx/include/__type_traits/is_copy_constructible.h --- a/libcxx/include/__type_traits/is_copy_constructible.h +++ b/libcxx/include/__type_traits/is_copy_constructible.h @@ -13,7 +13,6 @@ #include <__type_traits/add_const.h> #include <__type_traits/add_lvalue_reference.h> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_constructible.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -23,8 +22,9 @@ template struct _LIBCPP_TEMPLATE_VIS is_copy_constructible - : public is_constructible<_Tp, - typename add_lvalue_reference::type>::type> {}; + : public integral_constant< + bool, + __is_constructible(_Tp, typename add_lvalue_reference::type>::type)> {}; #if _LIBCPP_STD_VER > 14 template diff --git a/libcxx/include/__type_traits/is_default_constructible.h b/libcxx/include/__type_traits/is_default_constructible.h --- a/libcxx/include/__type_traits/is_default_constructible.h +++ b/libcxx/include/__type_traits/is_default_constructible.h @@ -11,7 +11,6 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_constructible.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -21,12 +20,12 @@ template struct _LIBCPP_TEMPLATE_VIS is_default_constructible - : public is_constructible<_Tp> + : public integral_constant {}; #if _LIBCPP_STD_VER > 14 template -inline constexpr bool is_default_constructible_v = is_default_constructible<_Tp>::value; +inline constexpr bool is_default_constructible_v = __is_constructible(_Tp); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_enum.h b/libcxx/include/__type_traits/is_enum.h --- a/libcxx/include/__type_traits/is_enum.h +++ b/libcxx/include/__type_traits/is_enum.h @@ -11,7 +11,6 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__type_traits/remove_cv.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/is_literal_type.h b/libcxx/include/__type_traits/is_literal_type.h --- a/libcxx/include/__type_traits/is_literal_type.h +++ b/libcxx/include/__type_traits/is_literal_type.h @@ -25,7 +25,7 @@ #if _LIBCPP_STD_VER > 14 template -_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = is_literal_type<_Tp>::value; +_LIBCPP_DEPRECATED_IN_CXX17 inline constexpr bool is_literal_type_v = __is_literal_type(_Tp); #endif // _LIBCPP_STD_VER > 14 #endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_TYPE_TRAITS) diff --git a/libcxx/include/__type_traits/is_move_assignable.h b/libcxx/include/__type_traits/is_move_assignable.h --- a/libcxx/include/__type_traits/is_move_assignable.h +++ b/libcxx/include/__type_traits/is_move_assignable.h @@ -10,11 +10,9 @@ #define _LIBCPP___TYPE_TRAITS_IS_MOVE_ASSIGNABLE_H #include <__config> -#include <__type_traits/add_const.h> #include <__type_traits/add_lvalue_reference.h> #include <__type_traits/add_rvalue_reference.h> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_assignable.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -22,9 +20,11 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template struct _LIBCPP_TEMPLATE_VIS is_move_assignable - : public is_assignable::type, - typename add_rvalue_reference<_Tp>::type> {}; +template +struct _LIBCPP_TEMPLATE_VIS is_move_assignable + : public integral_constant< + bool, + __is_assignable(typename add_lvalue_reference<_Tp>::type, typename add_rvalue_reference<_Tp>::type)> {}; #if _LIBCPP_STD_VER > 14 template diff --git a/libcxx/include/__type_traits/is_move_constructible.h b/libcxx/include/__type_traits/is_move_constructible.h --- a/libcxx/include/__type_traits/is_move_constructible.h +++ b/libcxx/include/__type_traits/is_move_constructible.h @@ -12,7 +12,6 @@ #include <__config> #include <__type_traits/add_rvalue_reference.h> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_constructible.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -22,7 +21,7 @@ template struct _LIBCPP_TEMPLATE_VIS is_move_constructible - : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> + : public integral_constant::type)> {}; #if _LIBCPP_STD_VER > 14 diff --git a/libcxx/include/__type_traits/is_nothrow_assignable.h b/libcxx/include/__type_traits/is_nothrow_assignable.h --- a/libcxx/include/__type_traits/is_nothrow_assignable.h +++ b/libcxx/include/__type_traits/is_nothrow_assignable.h @@ -10,7 +10,6 @@ #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_ASSIGNABLE_H #include <__config> -#include <__type_traits/add_const.h> #include <__type_traits/integral_constant.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -19,39 +18,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if __has_builtin(__is_nothrow_assignable) - template struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable : public integral_constant {}; -#else - -template struct __libcpp_is_nothrow_assignable; - -template -struct __libcpp_is_nothrow_assignable - : public false_type -{ -}; - -template -struct __libcpp_is_nothrow_assignable - : public integral_constant() = declval<_Arg>()) > -{ -}; - -template -struct _LIBCPP_TEMPLATE_VIS is_nothrow_assignable - : public __libcpp_is_nothrow_assignable::value, _Tp, _Arg> -{ -}; - -#endif // __has_builtin(__is_nothrow_assignable) - #if _LIBCPP_STD_VER > 14 template -inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value; +inline constexpr bool is_nothrow_assignable_v = __is_nothrow_assignable(_Tp, _Arg); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_nothrow_constructible.h b/libcxx/include/__type_traits/is_nothrow_constructible.h --- a/libcxx/include/__type_traits/is_nothrow_constructible.h +++ b/libcxx/include/__type_traits/is_nothrow_constructible.h @@ -11,7 +11,6 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__utility/declval.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -21,10 +20,10 @@ #if __has_builtin(__is_nothrow_constructible) -template +template < + class _Tp, class... _Args> struct _LIBCPP_TEMPLATE_VIS is_nothrow_constructible : public integral_constant {}; - #else template struct __libcpp_is_nothrow_constructible; diff --git a/libcxx/include/__type_traits/is_nothrow_copy_assignable.h b/libcxx/include/__type_traits/is_nothrow_copy_assignable.h --- a/libcxx/include/__type_traits/is_nothrow_copy_assignable.h +++ b/libcxx/include/__type_traits/is_nothrow_copy_assignable.h @@ -13,7 +13,6 @@ #include <__type_traits/add_const.h> #include <__type_traits/add_lvalue_reference.h> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_nothrow_assignable.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -21,9 +20,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable - : public is_nothrow_assignable::type, - typename add_lvalue_reference::type>::type> {}; +template +struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_assignable + : public integral_constant< + bool, + __is_nothrow_assignable( + typename add_lvalue_reference<_Tp>::type, + typename add_lvalue_reference::type>::type)> {}; #if _LIBCPP_STD_VER > 14 template diff --git a/libcxx/include/__type_traits/is_nothrow_copy_constructible.h b/libcxx/include/__type_traits/is_nothrow_copy_constructible.h --- a/libcxx/include/__type_traits/is_nothrow_copy_constructible.h +++ b/libcxx/include/__type_traits/is_nothrow_copy_constructible.h @@ -21,10 +21,23 @@ _LIBCPP_BEGIN_NAMESPACE_STD +// TODO: remove this implementation once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is fixed +#ifdef _LIBCPP_COMPILER_GCC + template struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible : public is_nothrow_constructible<_Tp, typename add_lvalue_reference::type>::type> {}; +#else // _LIBCPP_COMPILER_GCC + +template +struct _LIBCPP_TEMPLATE_VIS is_nothrow_copy_constructible + : public integral_constant< + bool, + __is_nothrow_constructible(_Tp, typename add_lvalue_reference::type>::type)> {}; + +#endif // _LIBCPP_COMPILER_GCC + #if _LIBCPP_STD_VER > 14 template inline constexpr bool is_nothrow_copy_constructible_v = is_nothrow_copy_constructible<_Tp>::value; diff --git a/libcxx/include/__type_traits/is_nothrow_default_constructible.h b/libcxx/include/__type_traits/is_nothrow_default_constructible.h --- a/libcxx/include/__type_traits/is_nothrow_default_constructible.h +++ b/libcxx/include/__type_traits/is_nothrow_default_constructible.h @@ -11,7 +11,6 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_nothrow_constructible.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -20,12 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD template struct _LIBCPP_TEMPLATE_VIS is_nothrow_default_constructible - : public is_nothrow_constructible<_Tp> + : public integral_constant {}; #if _LIBCPP_STD_VER > 14 template -inline constexpr bool is_nothrow_default_constructible_v = is_nothrow_default_constructible<_Tp>::value; +inline constexpr bool is_nothrow_default_constructible_v = __is_nothrow_constructible(_Tp); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_nothrow_destructible.h b/libcxx/include/__type_traits/is_nothrow_destructible.h --- a/libcxx/include/__type_traits/is_nothrow_destructible.h +++ b/libcxx/include/__type_traits/is_nothrow_destructible.h @@ -10,7 +10,6 @@ #define _LIBCPP___TYPE_TRAITS_IS_NOTHROW_DESTRUCTIBLE_H #include <__config> -#include <__type_traits/add_const.h> #include <__type_traits/integral_constant.h> #include <__type_traits/is_destructible.h> #include <__type_traits/is_reference.h> diff --git a/libcxx/include/__type_traits/is_nothrow_move_assignable.h b/libcxx/include/__type_traits/is_nothrow_move_assignable.h --- a/libcxx/include/__type_traits/is_nothrow_move_assignable.h +++ b/libcxx/include/__type_traits/is_nothrow_move_assignable.h @@ -13,7 +13,6 @@ #include <__type_traits/add_lvalue_reference.h> #include <__type_traits/add_rvalue_reference.h> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_nothrow_assignable.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -21,10 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable - : public is_nothrow_assignable::type, - typename add_rvalue_reference<_Tp>::type> - {}; +template +struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_assignable + : public integral_constant< + bool, + __is_nothrow_assignable(typename add_lvalue_reference<_Tp>::type, typename add_rvalue_reference<_Tp>::type)> { +}; #if _LIBCPP_STD_VER > 14 template diff --git a/libcxx/include/__type_traits/is_nothrow_move_constructible.h b/libcxx/include/__type_traits/is_nothrow_move_constructible.h --- a/libcxx/include/__type_traits/is_nothrow_move_constructible.h +++ b/libcxx/include/__type_traits/is_nothrow_move_constructible.h @@ -20,10 +20,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD +// TODO: remove this implementation once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is fixed +#ifndef _LIBCPP_COMPILER_GCC + +template struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible + : public integral_constant::type)> + {}; + +#else // _LIBCPP_COMPILER_GCC + template struct _LIBCPP_TEMPLATE_VIS is_nothrow_move_constructible : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> {}; +#endif // _LIBCPP_COMPILER_GCC + #if _LIBCPP_STD_VER > 14 template inline constexpr bool is_nothrow_move_constructible_v = is_nothrow_move_constructible<_Tp>::value; diff --git a/libcxx/include/__type_traits/is_pod.h b/libcxx/include/__type_traits/is_pod.h --- a/libcxx/include/__type_traits/is_pod.h +++ b/libcxx/include/__type_traits/is_pod.h @@ -18,24 +18,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD -#if __has_builtin(__is_pod) - template struct _LIBCPP_TEMPLATE_VIS is_pod : public integral_constant {}; -#else - -template struct _LIBCPP_TEMPLATE_VIS is_pod - : public integral_constant::value && - is_trivially_copy_constructible<_Tp>::value && - is_trivially_copy_assignable<_Tp>::value && - is_trivially_destructible<_Tp>::value> {}; - -#endif // __has_builtin(__is_pod) - #if _LIBCPP_STD_VER > 14 template -inline constexpr bool is_pod_v = is_pod<_Tp>::value; +inline constexpr bool is_pod_v = __is_pod(_Tp); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_standard_layout.h b/libcxx/include/__type_traits/is_standard_layout.h --- a/libcxx/include/__type_traits/is_standard_layout.h +++ b/libcxx/include/__type_traits/is_standard_layout.h @@ -19,16 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD template struct _LIBCPP_TEMPLATE_VIS is_standard_layout -#if __has_builtin(__is_standard_layout) : public integral_constant -#else - : integral_constant::type>::value> -#endif {}; #if _LIBCPP_STD_VER > 14 template -inline constexpr bool is_standard_layout_v = is_standard_layout<_Tp>::value; +inline constexpr bool is_standard_layout_v = __is_standard_layout(_Tp); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_trivial.h b/libcxx/include/__type_traits/is_trivial.h --- a/libcxx/include/__type_traits/is_trivial.h +++ b/libcxx/include/__type_traits/is_trivial.h @@ -19,17 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD template struct _LIBCPP_TEMPLATE_VIS is_trivial -#if __has_builtin(__is_trivial) : public integral_constant -#else - : integral_constant::value && - is_trivially_default_constructible<_Tp>::value> -#endif {}; #if _LIBCPP_STD_VER > 14 template -inline constexpr bool is_trivial_v = is_trivial<_Tp>::value; +inline constexpr bool is_trivial_v = __is_trivial(_Tp); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_trivially_assignable.h b/libcxx/include/__type_traits/is_trivially_assignable.h --- a/libcxx/include/__type_traits/is_trivially_assignable.h +++ b/libcxx/include/__type_traits/is_trivially_assignable.h @@ -25,7 +25,7 @@ #if _LIBCPP_STD_VER > 14 template -inline constexpr bool is_trivially_assignable_v = is_trivially_assignable<_Tp, _Arg>::value; +inline constexpr bool is_trivially_assignable_v = __is_trivially_assignable(_Tp, _Arg); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_trivially_constructible.h b/libcxx/include/__type_traits/is_trivially_constructible.h --- a/libcxx/include/__type_traits/is_trivially_constructible.h +++ b/libcxx/include/__type_traits/is_trivially_constructible.h @@ -26,7 +26,7 @@ #if _LIBCPP_STD_VER > 14 template -inline constexpr bool is_trivially_constructible_v = is_trivially_constructible<_Tp, _Args...>::value; +inline constexpr bool is_trivially_constructible_v = __is_trivially_constructible(_Tp, _Args...); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_trivially_copy_assignable.h b/libcxx/include/__type_traits/is_trivially_copy_assignable.h --- a/libcxx/include/__type_traits/is_trivially_copy_assignable.h +++ b/libcxx/include/__type_traits/is_trivially_copy_assignable.h @@ -13,7 +13,6 @@ #include <__type_traits/add_const.h> #include <__type_traits/add_lvalue_reference.h> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_trivially_assignable.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -21,9 +20,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable - : public is_trivially_assignable::type, - typename add_lvalue_reference::type>::type> {}; +template +struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_assignable + : public integral_constant< + bool, + __is_trivially_assignable( + typename add_lvalue_reference<_Tp>::type, + typename add_lvalue_reference::type>::type)> {}; #if _LIBCPP_STD_VER > 14 template diff --git a/libcxx/include/__type_traits/is_trivially_copy_constructible.h b/libcxx/include/__type_traits/is_trivially_copy_constructible.h --- a/libcxx/include/__type_traits/is_trivially_copy_constructible.h +++ b/libcxx/include/__type_traits/is_trivially_copy_constructible.h @@ -12,7 +12,6 @@ #include <__config> #include <__type_traits/add_lvalue_reference.h> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_trivially_constructible.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -21,7 +20,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template struct _LIBCPP_TEMPLATE_VIS is_trivially_copy_constructible - : public is_trivially_constructible<_Tp, typename add_lvalue_reference::type> + : public integral_constant::type)> {}; #if _LIBCPP_STD_VER > 14 diff --git a/libcxx/include/__type_traits/is_trivially_copyable.h b/libcxx/include/__type_traits/is_trivially_copyable.h --- a/libcxx/include/__type_traits/is_trivially_copyable.h +++ b/libcxx/include/__type_traits/is_trivially_copyable.h @@ -24,7 +24,7 @@ #if _LIBCPP_STD_VER > 14 template -inline constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value; +inline constexpr bool is_trivially_copyable_v = __is_trivially_copyable(_Tp); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_trivially_default_constructible.h b/libcxx/include/__type_traits/is_trivially_default_constructible.h --- a/libcxx/include/__type_traits/is_trivially_default_constructible.h +++ b/libcxx/include/__type_traits/is_trivially_default_constructible.h @@ -11,7 +11,6 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_trivially_constructible.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -20,12 +19,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD template struct _LIBCPP_TEMPLATE_VIS is_trivially_default_constructible - : public is_trivially_constructible<_Tp> + : public integral_constant {}; #if _LIBCPP_STD_VER > 14 template -inline constexpr bool is_trivially_default_constructible_v = is_trivially_default_constructible<_Tp>::value; +inline constexpr bool is_trivially_default_constructible_v = __is_trivially_constructible(_Tp); #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/is_trivially_destructible.h b/libcxx/include/__type_traits/is_trivially_destructible.h --- a/libcxx/include/__type_traits/is_trivially_destructible.h +++ b/libcxx/include/__type_traits/is_trivially_destructible.h @@ -30,15 +30,7 @@ #else -template struct __libcpp_trivial_destructor - : public integral_constant::value || - is_reference<_Tp>::value> {}; - -template struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible - : public __libcpp_trivial_destructor::type> {}; - -template struct _LIBCPP_TEMPLATE_VIS is_trivially_destructible<_Tp[]> - : public false_type {}; +#error is_trivially_destructible is not implemented #endif // __has_builtin(__is_trivially_destructible) diff --git a/libcxx/include/__type_traits/is_trivially_move_assignable.h b/libcxx/include/__type_traits/is_trivially_move_assignable.h --- a/libcxx/include/__type_traits/is_trivially_move_assignable.h +++ b/libcxx/include/__type_traits/is_trivially_move_assignable.h @@ -13,7 +13,6 @@ #include <__type_traits/add_lvalue_reference.h> #include <__type_traits/add_rvalue_reference.h> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_trivially_assignable.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -21,10 +20,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable - : public is_trivially_assignable::type, - typename add_rvalue_reference<_Tp>::type> - {}; +template +struct _LIBCPP_TEMPLATE_VIS is_trivially_move_assignable + : public integral_constant< + bool, + __is_trivially_assignable( + typename add_lvalue_reference<_Tp>::type, typename add_rvalue_reference<_Tp>::type)> {}; #if _LIBCPP_STD_VER > 14 template diff --git a/libcxx/include/__type_traits/is_trivially_move_constructible.h b/libcxx/include/__type_traits/is_trivially_move_constructible.h --- a/libcxx/include/__type_traits/is_trivially_move_constructible.h +++ b/libcxx/include/__type_traits/is_trivially_move_constructible.h @@ -12,7 +12,6 @@ #include <__config> #include <__type_traits/add_rvalue_reference.h> #include <__type_traits/integral_constant.h> -#include <__type_traits/is_trivially_constructible.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -20,9 +19,9 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible - : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> - {}; +template +struct _LIBCPP_TEMPLATE_VIS is_trivially_move_constructible + : public integral_constant::type)> {}; #if _LIBCPP_STD_VER > 14 template diff --git a/libcxx/include/__type_traits/is_union.h b/libcxx/include/__type_traits/is_union.h --- a/libcxx/include/__type_traits/is_union.h +++ b/libcxx/include/__type_traits/is_union.h @@ -11,7 +11,6 @@ #include <__config> #include <__type_traits/integral_constant.h> -#include <__type_traits/remove_cv.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header diff --git a/libcxx/include/__type_traits/negation.h b/libcxx/include/__type_traits/negation.h --- a/libcxx/include/__type_traits/negation.h +++ b/libcxx/include/__type_traits/negation.h @@ -25,7 +25,7 @@ template struct negation : _Not<_Tp> {}; template -inline constexpr bool negation_v = negation<_Tp>::value; +inline constexpr bool negation_v = !_Tp::value; #endif // _LIBCPP_STD_VER > 14 _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/rank.h b/libcxx/include/__type_traits/rank.h --- a/libcxx/include/__type_traits/rank.h +++ b/libcxx/include/__type_traits/rank.h @@ -19,6 +19,14 @@ _LIBCPP_BEGIN_NAMESPACE_STD +// TODO: Enable using the builtin __array_rank when https://llvm.org/PR57133 is resolved +#if __has_builtin(__array_rank) && 0 + +template +struct rank : integral_constant {}; + +#else + template struct _LIBCPP_TEMPLATE_VIS rank : public integral_constant {}; template struct _LIBCPP_TEMPLATE_VIS rank<_Tp[]> @@ -26,6 +34,8 @@ template struct _LIBCPP_TEMPLATE_VIS rank<_Tp[_Np]> : public integral_constant::value + 1> {}; +#endif // __has_builtin(__array_rank) + #if _LIBCPP_STD_VER > 14 template inline constexpr size_t rank_v = rank<_Tp>::value; diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/common.h b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/common.h new file mode 100644 --- /dev/null +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/common.h @@ -0,0 +1,47 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef TEST_META_UNARY_COMP_COMMON_H +#define TEST_META_UNARY_COMP_COMMON_H + +#include "test_macros.h" + +#if TEST_STD_VER >= 11 +struct TrivialNotNoexcept { + TrivialNotNoexcept() noexcept(false) = default; + TrivialNotNoexcept(const TrivialNotNoexcept&) noexcept(false) = default; + TrivialNotNoexcept(TrivialNotNoexcept&&) noexcept(false) = default; + TrivialNotNoexcept& operator=(const TrivialNotNoexcept&) noexcept(false) = default; + TrivialNotNoexcept& operator=(TrivialNotNoexcept&&) noexcept(false) = default; +}; +#endif + +class Empty {}; + +struct NotEmpty { + virtual ~NotEmpty(); +}; + +union Union {}; + +struct bit_zero { + int : 0; +}; + +struct A { + A(); + A(const A&); + A& operator=(const A&); +}; + +class Abstract +{ + virtual ~Abstract() = 0; +}; + +#endif // TEST_META_UNARY_COMP_COMMON_H diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp --- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_constructible.pass.cpp @@ -14,6 +14,8 @@ #include #include "test_macros.h" +#include "common.h" + template void test_is_nothrow_constructible() { @@ -59,32 +61,6 @@ #endif } -class Empty -{ -}; - -class NotEmpty -{ - virtual ~NotEmpty(); -}; - -union Union {}; - -struct bit_zero -{ - int : 0; -}; - -class Abstract -{ - virtual ~Abstract() = 0; -}; - -struct A -{ - A(const A&); -}; - struct C { C(C&); // not const diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp --- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_assignable.pass.cpp @@ -13,6 +13,8 @@ #include #include "test_macros.h" +#include "common.h" + template void test_has_nothrow_assign() { @@ -31,27 +33,6 @@ #endif } -class Empty -{ -}; - -struct NotEmpty -{ - virtual ~NotEmpty(); -}; - -union Union {}; - -struct bit_zero -{ - int : 0; -}; - -struct A -{ - A& operator=(const A&); -}; - int main(int, char**) { test_has_nothrow_assign(); @@ -64,6 +45,10 @@ test_has_nothrow_assign(); test_has_nothrow_assign(); +// TODO: enable the test for GCC once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is resolved +#if TEST_STD_VER >= 11 && !defined(TEST_COMPILER_GCC) + test_has_not_nothrow_assign(); +#endif test_has_not_nothrow_assign(); test_has_not_nothrow_assign(); test_has_not_nothrow_assign(); diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp --- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_copy_constructible.pass.cpp @@ -13,6 +13,8 @@ #include #include "test_macros.h" +#include "common.h" + template void test_is_nothrow_copy_constructible() { @@ -39,26 +41,13 @@ #endif } -class Empty -{ -}; - -union Union {}; - -struct bit_zero -{ - int : 0; -}; - -struct A -{ - A(const A&); -}; - int main(int, char**) { test_has_not_nothrow_copy_constructor(); test_has_not_nothrow_copy_constructor(); +#if TEST_STD_VER >= 11 + test_has_not_nothrow_copy_constructor(); +#endif test_is_nothrow_copy_constructible(); test_is_nothrow_copy_constructible(); diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp --- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_default_constructible.pass.cpp @@ -13,6 +13,8 @@ #include #include "test_macros.h" +#include "common.h" + template void test_is_nothrow_default_constructible() { @@ -43,22 +45,6 @@ #endif } -class Empty -{ -}; - -union Union {}; - -struct bit_zero -{ - int : 0; -}; - -struct A -{ - A(); -}; - #if TEST_STD_VER >= 11 struct DThrows { @@ -74,6 +60,10 @@ test_has_not_nothrow_default_constructor(); #if TEST_STD_VER >= 11 test_has_not_nothrow_default_constructor(); // This is LWG2116 +// TODO: enable the test for GCC once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is resolved +#ifndef TEST_COMPILER_GCC + test_has_not_nothrow_default_constructor(); +#endif #endif test_is_nothrow_default_constructible(); diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp --- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_assignable.pass.cpp @@ -13,6 +13,8 @@ #include #include "test_macros.h" +#include "common.h" + template void test_has_nothrow_assign() { @@ -31,27 +33,6 @@ #endif } -class Empty -{ -}; - -struct NotEmpty -{ - virtual ~NotEmpty(); -}; - -union Union {}; - -struct bit_zero -{ - int : 0; -}; - -struct A -{ - A& operator=(const A&); -}; - int main(int, char**) { test_has_nothrow_assign(); @@ -66,6 +47,10 @@ test_has_not_nothrow_assign(); test_has_not_nothrow_assign(); +// TODO: enable the test for GCC once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is resolved +#if TEST_STD_VER >= 11 && !defined(TEST_COMPILER_GCC) + test_has_not_nothrow_assign(); +#endif return 0; } diff --git a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp --- a/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp +++ b/libcxx/test/std/utilities/meta/meta.unary/meta.unary.prop/is_nothrow_move_constructible.pass.cpp @@ -13,6 +13,8 @@ #include #include "test_macros.h" +#include "common.h" + template void test_is_nothrow_move_constructible() { @@ -39,26 +41,14 @@ #endif } -class Empty -{ -}; - -union Union {}; - -struct bit_zero -{ - int : 0; -}; - -struct A -{ - A(const A&); -}; - int main(int, char**) { test_has_not_nothrow_move_constructor(); test_has_not_nothrow_move_constructor(); +// TODO: enable the test for GCC once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is resolved +#if TEST_STD_VER >= 11 && !defined(TEST_COMPILER_GCC) + test_has_not_nothrow_move_constructor(); +#endif test_is_nothrow_move_constructible(); test_is_nothrow_move_constructible();