diff options
Diffstat (limited to 'include/type_traits')
| -rw-r--r-- | include/type_traits | 726 |
1 files changed, 677 insertions, 49 deletions
diff --git a/include/type_traits b/include/type_traits index a0c1bc565c04..b7adfebceeb9 100644 --- a/include/type_traits +++ b/include/type_traits @@ -203,8 +203,160 @@ namespace std using result_of_t = typename result_of<F(ArgTypes...)>::type; // C++14 template <class...> - using void_t = void; -} // C++17 + using void_t = void; // C++17 + + // See C++14 20.10.4.1, primary type categories + template <class T> constexpr bool is_void_v + = is_void<T>::value; // C++17 + template <class T> constexpr bool is_null_pointer_v + = is_null_pointer<T>::value; // C++17 + template <class T> constexpr bool is_integral_v + = is_integral<T>::value; // C++17 + template <class T> constexpr bool is_floating_point_v + = is_floating_point<T>::value; // C++17 + template <class T> constexpr bool is_array_v + = is_array<T>::value; // C++17 + template <class T> constexpr bool is_pointer_v + = is_pointer<T>::value; // C++17 + template <class T> constexpr bool is_lvalue_reference_v + = is_lvalue_reference<T>::value; // C++17 + template <class T> constexpr bool is_rvalue_reference_v + = is_rvalue_reference<T>::value; // C++17 + template <class T> constexpr bool is_member_object_pointer_v + = is_member_object_pointer<T>::value; // C++17 + template <class T> constexpr bool is_member_function_pointer_v + = is_member_function_pointer<T>::value; // C++17 + template <class T> constexpr bool is_enum_v + = is_enum<T>::value; // C++17 + template <class T> constexpr bool is_union_v + = is_union<T>::value; // C++17 + template <class T> constexpr bool is_class_v + = is_class<T>::value; // C++17 + template <class T> constexpr bool is_function_v + = is_function<T>::value; // C++17 + + // See C++14 20.10.4.2, composite type categories + template <class T> constexpr bool is_reference_v + = is_reference<T>::value; // C++17 + template <class T> constexpr bool is_arithmetic_v + = is_arithmetic<T>::value; // C++17 + template <class T> constexpr bool is_fundamental_v + = is_fundamental<T>::value; // C++17 + template <class T> constexpr bool is_object_v + = is_object<T>::value; // C++17 + template <class T> constexpr bool is_scalar_v + = is_scalar<T>::value; // C++17 + template <class T> constexpr bool is_compound_v + = is_compound<T>::value; // C++17 + template <class T> constexpr bool is_member_pointer_v + = is_member_pointer<T>::value; // C++17 + + // See C++14 20.10.4.3, type properties + template <class T> constexpr bool is_const_v + = is_const<T>::value; // C++17 + template <class T> constexpr bool is_volatile_v + = is_volatile<T>::value; // C++17 + template <class T> constexpr bool is_trivial_v + = is_trivial<T>::value; // C++17 + template <class T> constexpr bool is_trivially_copyable_v + = is_trivially_copyable<T>::value; // C++17 + template <class T> constexpr bool is_standard_layout_v + = is_standard_layout<T>::value; // C++17 + template <class T> constexpr bool is_pod_v + = is_pod<T>::value; // C++17 + template <class T> constexpr bool is_literal_type_v + = is_literal_type<T>::value; // C++17 + template <class T> constexpr bool is_empty_v + = is_empty<T>::value; // C++17 + template <class T> constexpr bool is_polymorphic_v + = is_polymorphic<T>::value; // C++17 + template <class T> constexpr bool is_abstract_v + = is_abstract<T>::value; // C++17 + template <class T> constexpr bool is_final_v + = is_final<T>::value; // C++17 + template <class T> constexpr bool is_signed_v + = is_signed<T>::value; // C++17 + template <class T> constexpr bool is_unsigned_v + = is_unsigned<T>::value; // C++17 + template <class T, class... Args> constexpr bool is_constructible_v + = is_constructible<T, Args...>::value; // C++17 + template <class T> constexpr bool is_default_constructible_v + = is_default_constructible<T>::value; // C++17 + template <class T> constexpr bool is_copy_constructible_v + = is_copy_constructible<T>::value; // C++17 + template <class T> constexpr bool is_move_constructible_v + = is_move_constructible<T>::value; // C++17 + template <class T, class U> constexpr bool is_assignable_v + = is_assignable<T, U>::value; // C++17 + template <class T> constexpr bool is_copy_assignable_v + = is_copy_assignable<T>::value; // C++17 + template <class T> constexpr bool is_move_assignable_v + = is_move_assignable<T>::value; // C++17 + template <class T> constexpr bool is_destructible_v + = is_destructible<T>::value; // C++17 + template <class T, class... Args> constexpr bool is_trivially_constructible_v + = is_trivially_constructible<T, Args...>::value; // C++17 + template <class T> constexpr bool is_trivially_default_constructible_v + = is_trivially_default_constructible<T>::value; // C++17 + template <class T> constexpr bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible<T>::value; // C++17 + template <class T> constexpr bool is_trivially_move_constructible_v + = is_trivially_move_constructible<T>::value; // C++17 + template <class T, class U> constexpr bool is_trivially_assignable_v + = is_trivially_assignable<T, U>::value; // C++17 + template <class T> constexpr bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable<T>::value; // C++17 + template <class T> constexpr bool is_trivially_move_assignable_v + = is_trivially_move_assignable<T>::value; // C++17 + template <class T> constexpr bool is_trivially_destructible_v + = is_trivially_destructible<T>::value; // C++17 + template <class T, class... Args> constexpr bool is_nothrow_constructible_v + = is_nothrow_constructible<T, Args...>::value; // C++17 + template <class T> constexpr bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible<T>::value; // C++17 + template <class T> constexpr bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible<T>::value; // C++17 + template <class T> constexpr bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible<T>::value; // C++17 + template <class T, class U> constexpr bool is_nothrow_assignable_v + = is_nothrow_assignable<T, U>::value; // C++17 + template <class T> constexpr bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable<T>::value; // C++17 + template <class T> constexpr bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable<T>::value; // C++17 + template <class T> constexpr bool is_nothrow_destructible_v + = is_nothrow_destructible<T>::value; // C++17 + template <class T> constexpr bool has_virtual_destructor_v + = has_virtual_destructor<T>::value; // C++17 + + // See C++14 20.10.5, type property queries + template <class T> constexpr size_t alignment_of_v + = alignment_of<T>::value; // C++17 + template <class T> constexpr size_t rank_v + = rank<T>::value; // C++17 + template <class T, unsigned I = 0> constexpr size_t extent_v + = extent<T, I>::value; // C++17 + + // See C++14 20.10.6, type relations + template <class T, class U> constexpr bool is_same_v + = is_same<T, U>::value; // C++17 + template <class Base, class Derived> constexpr bool is_base_of_v + = is_base_of<Base, Derived>::value; // C++17 + template <class From, class To> constexpr bool is_convertible_v + = is_convertible<From, To>::value; // C++17 + + // [meta.logical], logical operator traits: + template<class... B> struct conjunction; // C++17 + template<class... B> + constexpr bool conjunction_v = conjunction<B...>::value; // C++17 + template<class... B> struct disjunction; // C++17 + template<class... B> + constexpr bool disjunction_v = disjunction<B...>::value; // C++17 + template<class B> struct negation; // C++17 + template<class B> + constexpr bool negation_v = negation<B>::value; // C++17 + +} */ #include <__config> @@ -244,6 +396,55 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type; #endif +// addressof + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +_Tp* +addressof(_Tp& __x) _NOEXCEPT +{ + return (_Tp*)&reinterpret_cast<const volatile char&>(__x); +} + +#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) +// Objective-C++ Automatic Reference Counting uses qualified pointers +// that require special addressof() signatures. When +// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler +// itself is providing these definitions. Otherwise, we provide them. +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +__strong _Tp* +addressof(__strong _Tp& __x) _NOEXCEPT +{ + return &__x; +} + +#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +__weak _Tp* +addressof(__weak _Tp& __x) _NOEXCEPT +{ + return &__x; +} +#endif + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +__autoreleasing _Tp* +addressof(__autoreleasing _Tp& __x) _NOEXCEPT +{ + return &__x; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +__unsafe_unretained _Tp* +addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT +{ + return &__x; +} +#endif struct __two {char __lx[2];}; @@ -269,24 +470,111 @@ _LIBCPP_CONSTEXPR const _Tp integral_constant<_Tp, __v>::value; #if _LIBCPP_STD_VER > 14 template <bool __b> using bool_constant = integral_constant<bool, __b>; -#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> +#define _LIBCPP_BOOL_CONSTANT(__b) bool_constant<(__b)> #else -#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)> +#define _LIBCPP_BOOL_CONSTANT(__b) integral_constant<bool,(__b)> #endif typedef _LIBCPP_BOOL_CONSTANT(true) true_type; typedef _LIBCPP_BOOL_CONSTANT(false) false_type; +#if !defined(_LIBCPP_HAS_NO_VARIADICS) + +// __lazy_and + +template <bool _Last, class ..._Preds> +struct __lazy_and_impl; + +template <class ..._Preds> +struct __lazy_and_impl<false, _Preds...> : false_type {}; + +template <> +struct __lazy_and_impl<true> : true_type {}; + +template <class _Pred> +struct __lazy_and_impl<true, _Pred> : integral_constant<bool, _Pred::type::value> {}; + +template <class _Hp, class ..._Tp> +struct __lazy_and_impl<true, _Hp, _Tp...> : __lazy_and_impl<_Hp::type::value, _Tp...> {}; + +template <class _P1, class ..._Pr> +struct __lazy_and : __lazy_and_impl<_P1::type::value, _Pr...> {}; + +// __lazy_or + +template <bool _List, class ..._Preds> +struct __lazy_or_impl; + +template <class ..._Preds> +struct __lazy_or_impl<true, _Preds...> : true_type {}; + +template <> +struct __lazy_or_impl<false> : false_type {}; + +template <class _Hp, class ..._Tp> +struct __lazy_or_impl<false, _Hp, _Tp...> + : __lazy_or_impl<_Hp::type::value, _Tp...> {}; + +template <class _P1, class ..._Pr> +struct __lazy_or : __lazy_or_impl<_P1::type::value, _Pr...> {}; + +// __lazy_not + +template <class _Pred> +struct __lazy_not : integral_constant<bool, !_Pred::type::value> {}; + +// __and_ +template<class...> struct __and_; +template<> struct __and_<> : true_type {}; + +template<class _B0> struct __and_<_B0> : _B0 {}; + +template<class _B0, class _B1> +struct __and_<_B0, _B1> : conditional<_B0::value, _B1, _B0>::type {}; + +template<class _B0, class _B1, class _B2, class... _Bn> +struct __and_<_B0, _B1, _B2, _Bn...> + : conditional<_B0::value, __and_<_B1, _B2, _Bn...>, _B0>::type {}; + +// __or_ +template<class...> struct __or_; +template<> struct __or_<> : false_type {}; + +template<class _B0> struct __or_<_B0> : _B0 {}; + +template<class _B0, class _B1> +struct __or_<_B0, _B1> : conditional<_B0::value, _B0, _B1>::type {}; + +template<class _B0, class _B1, class _B2, class... _Bn> +struct __or_<_B0, _B1, _B2, _Bn...> + : conditional<_B0::value, _B0, __or_<_B1, _B2, _Bn...> >::type {}; + +// __not_ +template<class _Tp> +struct __not_ : conditional<_Tp::value, false_type, true_type>::type {}; + +#endif // !defined(_LIBCPP_HAS_NO_VARIADICS) + // is_const template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {}; template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_const_v + = is_const<_Tp>::value; +#endif + // is_volatile template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {}; template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_volatile_v + = is_volatile<_Tp>::value; +#endif + // remove_const template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; @@ -319,6 +607,11 @@ template <> struct __libcpp_is_void<void> : public true_type {}; template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void : public __libcpp_is_void<typename remove_cv<_Tp>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_void_v + = is_void<_Tp>::value; +#endif + // __is_nullptr_t template <class _Tp> struct __is_nullptr_t_impl : public false_type {}; @@ -330,6 +623,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t #if _LIBCPP_STD_VER > 11 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer : public __is_nullptr_t_impl<typename remove_cv<_Tp>::type> {}; + +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_null_pointer_v + = is_null_pointer<_Tp>::value; +#endif #endif // is_integral @@ -360,6 +658,11 @@ template <> struct __libcpp_is_integral<__uint128_t> : public tr template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral : public __libcpp_is_integral<typename remove_cv<_Tp>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_integral_v + = is_integral<_Tp>::value; +#endif + // is_floating_point template <class _Tp> struct __libcpp_is_floating_point : public false_type {}; @@ -370,6 +673,11 @@ template <> struct __libcpp_is_floating_point<long double> : public tru template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point : public __libcpp_is_floating_point<typename remove_cv<_Tp>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_floating_point_v + = is_floating_point<_Tp>::value; +#endif + // is_array template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array @@ -379,6 +687,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]> template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_array_v + = is_array<_Tp>::value; +#endif + // is_pointer template <class _Tp> struct __libcpp_is_pointer : public false_type {}; @@ -387,6 +700,11 @@ template <class _Tp> struct __libcpp_is_pointer<_Tp*> : public true_type {}; template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer : public __libcpp_is_pointer<typename remove_cv<_Tp>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_pointer_v + = is_pointer<_Tp>::value; +#endif + // is_reference template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {}; @@ -403,6 +721,16 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public t template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {}; #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_reference_v + = is_reference<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_lvalue_reference_v + = is_lvalue_reference<_Tp>::value; + +template <class _Tp> _LIBCPP_CONSTEXPR bool is_rvalue_reference_v + = is_rvalue_reference<_Tp>::value; +#endif // is_union #if __has_feature(is_union) || (_GNUC_VER >= 403) @@ -418,6 +746,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_union_v + = is_union<_Tp>::value; +#endif + // is_class #if __has_feature(is_class) || (_GNUC_VER >= 403) @@ -438,11 +771,21 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_class_v + = is_class<_Tp>::value; +#endif + // is_same template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {}; template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp, class _Up> _LIBCPP_CONSTEXPR bool is_same_v + = is_same<_Tp, _Up>::value; +#endif + // is_function namespace __libcpp_is_function_imp @@ -468,13 +811,18 @@ template <class _Tp> struct __libcpp_is_function<_Tp, true> : public false_type template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function : public __libcpp_is_function<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_function_v + = is_function<_Tp>::value; +#endif + // is_member_function_pointer // template <class _Tp> struct __libcpp_is_member_function_pointer : public false_type {}; // template <class _Tp, class _Up> struct __libcpp_is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; // -template <class _MP, bool _IsMemberFuctionPtr, bool _IsMemberObjectPtr> +template <class _MP, bool _IsMemberFunctionPtr, bool _IsMemberObjectPtr> struct __member_pointer_traits_imp { // forward declaration; specializations later }; @@ -490,6 +838,11 @@ struct __libcpp_is_member_function_pointer<_Ret _Class::*> template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer : public __libcpp_is_member_function_pointer<typename remove_cv<_Tp>::type>::type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_function_pointer_v + = is_member_function_pointer<_Tp>::value; +#endif + // is_member_pointer template <class _Tp> struct __libcpp_is_member_pointer : public false_type {}; @@ -498,12 +851,22 @@ template <class _Tp, class _Up> struct __libcpp_is_member_pointer<_Tp _Up::*> : template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer : public __libcpp_is_member_pointer<typename remove_cv<_Tp>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_pointer_v + = is_member_pointer<_Tp>::value; +#endif + // is_member_object_pointer template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer : public integral_constant<bool, is_member_pointer<_Tp>::value && !is_member_function_pointer<_Tp>::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_member_object_pointer_v + = is_member_object_pointer<_Tp>::value; +#endif + // is_enum #if __has_feature(is_enum) || (_GNUC_VER >= 403) @@ -527,12 +890,22 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_enum_v + = is_enum<_Tp>::value; +#endif + // is_arithmetic template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic : public integral_constant<bool, is_integral<_Tp>::value || is_floating_point<_Tp>::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_arithmetic_v + = is_arithmetic<_Tp>::value; +#endif + // is_fundamental template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental @@ -540,6 +913,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_fundamental_v + = is_fundamental<_Tp>::value; +#endif + // is_scalar template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar @@ -551,6 +929,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_scalar_v + = is_scalar<_Tp>::value; +#endif + // is_object template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object @@ -559,11 +942,21 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object is_union<_Tp>::value || is_class<_Tp>::value > {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_object_v + = is_object<_Tp>::value; +#endif + // is_compound template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_compound_v + = is_compound<_Tp>::value; +#endif + // add_const template <class _Tp, bool = is_reference<_Tp>::value || @@ -701,6 +1094,11 @@ template <class _Tp> struct __libcpp_is_signed<_Tp, false> : public false_type { template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __libcpp_is_signed<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_signed_v + = is_signed<_Tp>::value; +#endif + // is_unsigned template <class _Tp, bool = is_integral<_Tp>::value> @@ -716,6 +1114,11 @@ template <class _Tp> struct __libcpp_is_unsigned<_Tp, false> : public false_type template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __libcpp_is_unsigned<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_unsigned_v + = is_unsigned<_Tp>::value; +#endif + // rank template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank @@ -725,6 +1128,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]> template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]> : public integral_constant<size_t, rank<_Tp>::value + 1> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR size_t rank_v + = rank<_Tp>::value; +#endif + // extent template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent @@ -738,6 +1146,11 @@ template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0 template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp, unsigned _Ip = 0> _LIBCPP_CONSTEXPR size_t extent_v + = extent<_Tp, _Ip>::value; +#endif + // remove_extent template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent @@ -804,6 +1217,11 @@ template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {} template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_abstract_v + = is_abstract<_Tp>::value; +#endif + // is_final #if defined(_LIBCPP_HAS_IS_FINAL) @@ -819,6 +1237,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_final : public integral_constant<bool, __is_final(_Tp)> {}; #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_final_v + = is_final<_Tp>::value; +#endif + // is_base_of #ifdef _LIBCPP_HAS_IS_BASE_OF @@ -854,6 +1277,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_base_of #endif // _LIBCPP_HAS_IS_BASE_OF +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Bp, class _Dp> _LIBCPP_CONSTEXPR bool is_base_of_v + = is_base_of<_Bp, _Dp>::value; +#endif + // is_convertible #if __has_feature(is_convertible_to) && !defined(_LIBCPP_USE_IS_CONVERTIBLE_FALLBACK) @@ -981,6 +1409,11 @@ template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible #endif // __has_feature(is_convertible_to) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _From, class _To> _LIBCPP_CONSTEXPR bool is_convertible_v + = is_convertible<_From, _To>::value; +#endif + // is_empty #if __has_feature(is_empty) || (_GNUC_VER >= 407) @@ -1012,6 +1445,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_emp #endif // __has_feature(is_empty) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_empty_v + = is_empty<_Tp>::value; +#endif + // is_polymorphic #if __has_feature(is_polymorphic) || defined(_LIBCPP_MSVC) @@ -1032,6 +1470,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic #endif // __has_feature(is_polymorphic) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_polymorphic_v + = is_polymorphic<_Tp>::value; +#endif + // has_virtual_destructor #if __has_feature(has_virtual_destructor) || (_GNUC_VER >= 403) @@ -1046,11 +1489,21 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool has_virtual_destructor_v + = has_virtual_destructor<_Tp>::value; +#endif + // alignment_of template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of : public integral_constant<size_t, __alignof__(_Tp)> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR size_t alignment_of_v + = alignment_of<_Tp>::value; +#endif + // aligned_storage template <class _Hp, class _Tp> @@ -1143,7 +1596,7 @@ struct _LIBCPP_TYPE_VIS_ONLY aligned_storage union type { _Aligner __align; - unsigned char __data[_Len]; + unsigned char __data[(_Len + _Align - 1)/_Align * _Align]; }; }; @@ -1158,7 +1611,7 @@ struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\ {\ struct _ALIGNAS(n) type\ {\ - unsigned char __lx[_Len];\ + unsigned char __lx[(_Len + n - 1)/n * n];\ };\ } @@ -1290,18 +1743,6 @@ public: template <class _A1, class _A2 = void, class _A3 = void> class __promote : public __promote_imp<_A1, _A2, _A3> {}; -#ifdef _LIBCPP_STORE_AS_OPTIMIZATION - -// __transform - -template <class _Tp, size_t = sizeof(_Tp), bool = is_scalar<_Tp>::value> struct __transform {typedef _Tp type;}; -template <class _Tp> struct __transform<_Tp, 1, true> {typedef unsigned char type;}; -template <class _Tp> struct __transform<_Tp, 2, true> {typedef unsigned short type;}; -template <class _Tp> struct __transform<_Tp, 4, true> {typedef unsigned int type;}; -template <class _Tp> struct __transform<_Tp, 8, true> {typedef unsigned long long type;}; - -#endif // _LIBCPP_STORE_AS_OPTIMIZATION - // make_signed / make_unsigned typedef @@ -1482,21 +1923,19 @@ public: template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void> { -private: -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - static _Tp&& __t(); - static _Up&& __u(); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - static _Tp __t(); - static _Up __u(); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -public: - typedef typename remove_reference<decltype(true ? __t() : __u())>::type type; + typedef typename decay<decltype( + true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>() + )>::type type; }; #else // _LIBCPP_HAS_NO_VARIADICS -template <class ..._Tp> struct common_type; +// bullet 1 - sizeof...(Tp) == 0 + +template <class ..._Tp> +struct _LIBCPP_TYPE_VIS_ONLY common_type {}; + +// bullet 2 - sizeof...(Tp) == 1 template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> @@ -1504,23 +1943,46 @@ struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> typedef typename decay<_Tp>::type type; }; +// bullet 3 - sizeof...(Tp) == 2 + +template <class _Tp, class _Up, class = void> +struct __common_type2 {}; + template <class _Tp, class _Up> -struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up> +struct __common_type2<_Tp, _Up, + typename __void_t<decltype( + true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>() + )>::type> { -private: - static _Tp&& __t(); - static _Up&& __u(); - static bool __f(); -public: - typedef typename decay<decltype(__f() ? __t() : __u())>::type type; + typedef typename decay<decltype( + true ? _VSTD::declval<_Tp>() : _VSTD::declval<_Up>() + )>::type type; }; +template <class _Tp, class _Up> +struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up> + : __common_type2<_Tp, _Up> {}; + +// bullet 4 - sizeof...(Tp) > 2 + +template <class ...Tp> struct __common_types; + +template <class, class = void> +struct __common_type_impl {}; + template <class _Tp, class _Up, class ..._Vp> -struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...> +struct __common_type_impl<__common_types<_Tp, _Up, _Vp...>, + typename __void_t<typename common_type<_Tp, _Up>::type>::type> { - typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type; + typedef typename common_type< + typename common_type<_Tp, _Up>::type, _Vp... + >::type type; }; +template <class _Tp, class _Up, class ..._Vp> +struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...> + : __common_type_impl<__common_types<_Tp, _Up, _Vp...> > {}; + #if _LIBCPP_STD_VER > 11 template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type; #endif @@ -1564,12 +2026,22 @@ template <class _Tp, class _Arg> struct is_assignable : public __is_assignable_imp<_Tp, _Arg> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_assignable_v + = is_assignable<_Tp, _Arg>::value; +#endif + // is_copy_assignable template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable : public is_assignable<typename add_lvalue_reference<_Tp>::type, typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_assignable_v + = is_copy_assignable<_Tp>::value; +#endif + // is_move_assignable template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable @@ -1580,6 +2052,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable : public is_copy_assignable<_Tp> {}; #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_assignable_v + = is_move_assignable<_Tp>::value; +#endif + // is_destructible // if it's a reference, return true @@ -1638,6 +2115,11 @@ template <> struct is_destructible<void> : public _VSTD::false_type {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_destructible_v + = is_destructible<_Tp>::value; +#endif + // move #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -2672,6 +3154,11 @@ struct __is_constructible2_imp<false, _Ap[], _A0, _A1> #endif // _LIBCPP_HAS_NO_VARIADICS #endif // __has_feature(is_constructible) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) +template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_constructible_v + = is_constructible<_Tp, _Args...>::value; +#endif + // is_default_constructible template <class _Tp> @@ -2679,6 +3166,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible : public is_constructible<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_default_constructible_v + = is_default_constructible<_Tp>::value; +#endif + // is_copy_constructible template <class _Tp> @@ -2686,6 +3178,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible : public is_constructible<_Tp, typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_copy_constructible_v + = is_copy_constructible<_Tp>::value; +#endif + // is_move_constructible template <class _Tp> @@ -2697,6 +3194,11 @@ struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_move_constructible_v + = is_move_constructible<_Tp>::value; +#endif + // is_trivially_constructible #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -2824,18 +3326,33 @@ struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, #endif // _LIBCPP_HAS_NO_VARIADICS +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) +template <class _Tp, class... _Args> _LIBCPP_CONSTEXPR bool is_trivially_constructible_v + = is_trivially_constructible<_Tp, _Args...>::value; +#endif + // is_trivially_default_constructible template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible : public is_trivially_constructible<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_default_constructible_v + = is_trivially_default_constructible<_Tp>::value; +#endif + // is_trivially_copy_constructible template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible : public is_trivially_constructible<_Tp, typename add_lvalue_reference<const _Tp>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_constructible_v + = is_trivially_copy_constructible<_Tp>::value; +#endif + // is_trivially_move_constructible template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible @@ -2846,6 +3363,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructibl #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_constructible_v + = is_trivially_move_constructible<_Tp>::value; +#endif + // is_trivially_assignable #if __has_feature(is_trivially_assignable) || _GNUC_VER >= 501 @@ -2884,12 +3406,22 @@ struct is_trivially_assignable<_Tp&, _Tp&&> #endif // !__has_feature(is_trivially_assignable) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_trivially_assignable_v + = is_trivially_assignable<_Tp, _Arg>::value; +#endif + // is_trivially_copy_assignable template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copy_assignable_v + = is_trivially_copy_assignable<_Tp>::value; +#endif + // is_trivially_move_assignable template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable @@ -2901,6 +3433,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_move_assignable_v + = is_trivially_move_assignable<_Tp>::value; +#endif + // is_trivially_destructible #if __has_feature(has_trivial_destructor) || (_GNUC_VER >= 403) @@ -2917,6 +3454,14 @@ template <class _Tp> struct __libcpp_trivial_destructor template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible<_Tp[]> + : public false_type {}; + +#endif + +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_destructible_v + = is_trivially_destructible<_Tp>::value; #endif // is_nothrow_constructible @@ -3079,18 +3624,33 @@ struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&, #endif // _LIBCPP_HAS_NO_VARIADICS #endif // __has_feature(is_nothrow_constructible) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) && !defined(_LIBCPP_HAS_NO_VARIADICS) +template <class _Tp, class ..._Args> _LIBCPP_CONSTEXPR bool is_nothrow_constructible_v + = is_nothrow_constructible<_Tp, _Args...>::value; +#endif + // is_nothrow_default_constructible template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible : public is_nothrow_constructible<_Tp> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_default_constructible_v + = is_nothrow_default_constructible<_Tp>::value; +#endif + // is_nothrow_copy_constructible template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible : public is_nothrow_constructible<_Tp, typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_constructible_v + = is_nothrow_copy_constructible<_Tp>::value; +#endif + // is_nothrow_move_constructible template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible @@ -3101,6 +3661,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_constructible_v + = is_nothrow_move_constructible<_Tp>::value; +#endif + // is_nothrow_assignable #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) @@ -3169,12 +3734,22 @@ struct is_nothrow_assignable<_Tp&, _Tp&&> #endif // __has_feature(cxx_noexcept) +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp, class _Arg> _LIBCPP_CONSTEXPR bool is_nothrow_assignable_v + = is_nothrow_assignable<_Tp, _Arg>::value; +#endif + // is_nothrow_copy_assignable template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, typename add_lvalue_reference<typename add_const<_Tp>::type>::type> {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_copy_assignable_v + = is_nothrow_copy_assignable<_Tp>::value; +#endif + // is_nothrow_move_assignable template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable @@ -3186,6 +3761,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_move_assignable_v + = is_nothrow_move_assignable<_Tp>::value; +#endif + // is_nothrow_destructible #if __has_feature(cxx_noexcept) || (_GNUC_VER >= 407 && __cplusplus >= 201103L) @@ -3241,6 +3821,15 @@ template <class _Tp> struct __libcpp_nothrow_destructor template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; +template <class _Tp> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[]> + : public false_type {}; + +#endif + +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_nothrow_destructible_v + = is_nothrow_destructible<_Tp>::value; #endif // is_pod @@ -3260,6 +3849,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod #endif +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_pod_v + = is_pod<_Tp>::value; +#endif + // is_literal_type; template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type @@ -3271,6 +3865,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_literal_type_v + = is_literal_type<_Tp>::value; +#endif + // is_standard_layout; template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout @@ -3281,6 +3880,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_standard_layout_v + = is_standard_layout<_Tp>::value; +#endif + // is_trivially_copyable; template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable @@ -3293,6 +3897,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivially_copyable_v + = is_trivially_copyable<_Tp>::value; +#endif + // is_trivial; template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial @@ -3304,6 +3913,11 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial #endif {}; +#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) +template <class _Tp> _LIBCPP_CONSTEXPR bool is_trivial_v + = is_trivial<_Tp>::value; +#endif + #ifndef _LIBCPP_HAS_NO_VARIADICS // Check for complete types @@ -3692,34 +4306,34 @@ struct __sfinae_underlying_type template <class _Tp> struct __sfinae_underlying_type<_Tp, false> {}; -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY int __convert_to_integral(int __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY unsigned __convert_to_integral(unsigned __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY long __convert_to_integral(long __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY unsigned long __convert_to_integral(unsigned long __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY long long __convert_to_integral(long long __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY unsigned long long __convert_to_integral(unsigned long long __val) {return __val; } #ifndef _LIBCPP_HAS_NO_INT128 -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY __int128_t __convert_to_integral(__int128_t __val) { return __val; } -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY __uint128_t __convert_to_integral(__uint128_t __val) { return __val; } #endif template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_ALWAYS_INLINE +inline _LIBCPP_INLINE_VISIBILITY typename __sfinae_underlying_type<_Tp>::__promoted_type __convert_to_integral(_Tp __val) { return __val; } @@ -3759,7 +4373,21 @@ struct __has_operator_addressof #if _LIBCPP_STD_VER > 14 template <class...> using void_t = void; -#endif + +# ifndef _LIBCPP_HAS_NO_VARIADICS +template <class... _Args> +struct conjunction : __and_<_Args...> {}; +template<class... _Args> constexpr bool conjunction_v = conjunction<_Args...>::value; + +template <class... _Args> +struct disjunction : __or_<_Args...> {}; +template<class... _Args> constexpr bool disjunction_v = disjunction<_Args...>::value; + +template <class _Tp> +struct negation : __not_<_Tp> {}; +template<class _Tp> constexpr bool negation_v = negation<_Tp>::value; +# endif // _LIBCPP_HAS_NO_VARIADICS +#endif // _LIBCPP_STD_VER > 14 _LIBCPP_END_NAMESPACE_STD |
