diff --git a/libcxx/include/__type_traits/conditional.h b/libcxx/include/__type_traits/conditional.h --- a/libcxx/include/__type_traits/conditional.h +++ b/libcxx/include/__type_traits/conditional.h @@ -17,13 +17,32 @@ _LIBCPP_BEGIN_NAMESPACE_STD +template +struct _IfImpl; + +template <> +struct _IfImpl { + template + using _Select _LIBCPP_NODEBUG = _If; +}; + +template <> +struct _IfImpl { + template + using _Select _LIBCPP_NODEBUG = _Else; +}; + +template +using _If _LIBCPP_NODEBUG = typename _IfImpl<_Cond>::template _Select<_IfRes, _ElseRes>; + template struct _LIBCPP_TEMPLATE_VIS conditional {typedef _If type;}; template struct _LIBCPP_TEMPLATE_VIS conditional {typedef _Then type;}; #if _LIBCPP_STD_VER > 11 -template using conditional_t = typename conditional<_Bp, _If, _Then>::type; +template +using conditional_t = _If<_Bp, _IfRes, _ElseRes>; #endif _LIBCPP_END_NAMESPACE_STD diff --git a/libcxx/include/__type_traits/conjunction.h b/libcxx/include/__type_traits/conjunction.h --- a/libcxx/include/__type_traits/conjunction.h +++ b/libcxx/include/__type_traits/conjunction.h @@ -11,16 +11,17 @@ #include <__config> #include <__type_traits/conditional.h> +#include <__type_traits/enable_if.h> #include <__type_traits/integral_constant.h> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif -#if _LIBCPP_STD_VER > 14 - _LIBCPP_BEGIN_NAMESPACE_STD +#if _LIBCPP_STD_VER > 14 + template struct __conjunction_impl { using type = conditional_t::type>; @@ -37,8 +38,20 @@ template inline constexpr bool conjunction_v = conjunction<_Args...>::value; -_LIBCPP_END_NAMESPACE_STD - #endif // _LIBCPP_STD_VER > 14 +template +using __expand_to_true = true_type; + +template +__expand_to_true<__enable_if_t<_Pred::value>...> __and_helper(int); + +template +false_type __and_helper(...); + +template +using _And _LIBCPP_NODEBUG = decltype(__and_helper<_Pred...>(0)); + +_LIBCPP_END_NAMESPACE_STD + #endif // _LIBCPP___TYPE_TRAITS_CONJUNCTION_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 @@ -17,27 +17,37 @@ # pragma GCC system_header #endif -#if _LIBCPP_STD_VER > 14 - _LIBCPP_BEGIN_NAMESPACE_STD -template -struct __disjunction_impl { - using type = conditional_t::type>; +template +struct _OrImpl; + +template <> +struct _OrImpl { + template + using _Result _LIBCPP_NODEBUG = + typename _OrImpl::template _Result<_First, _Rest...>; }; -template -struct __disjunction_impl<_Arg> { - using type = _Arg; +template <> +struct _OrImpl { + template + using _Result = _Res; }; template -struct disjunction : __disjunction_impl::type {}; -template -inline constexpr bool disjunction_v = disjunction<_Args...>::value; +using _Or _LIBCPP_NODEBUG = typename _OrImpl::template _Result; -_LIBCPP_END_NAMESPACE_STD +#if _LIBCPP_STD_VER > 14 + +template +struct disjunction : _Or<_Args...> {}; + +template +inline constexpr bool disjunction_v = _Or<_Args...>::value; #endif // _LIBCPP_STD_VER > 14 +_LIBCPP_END_NAMESPACE_STD + #endif // _LIBCPP___TYPE_TRAITS_DISJUNCTION_H diff --git a/libcxx/include/type_traits b/libcxx/include/type_traits --- a/libcxx/include/type_traits +++ b/libcxx/include/type_traits @@ -531,44 +531,25 @@ template struct _MetaBase; template <> struct _MetaBase { - template - using _SelectImpl _LIBCPP_NODEBUG = _Tp; template