diff --git a/include/cetl/pf17/type_traits.hpp b/include/cetl/pf17/type_traits.hpp index 424b3566..ab55b26a 100644 --- a/include/cetl/pf17/type_traits.hpp +++ b/include/cetl/pf17/type_traits.hpp @@ -30,6 +30,54 @@ constexpr bool is_nothrow_swappable = noexcept(swap(std::declval(), std::dec template constexpr bool is_nothrow_swappable_v = detail::type_traits::is_nothrow_swappable; +/// Implementation of \ref std::conjunction. +template +struct conjunction : std::true_type +{}; +template +struct conjunction : A +{}; +template +struct conjunction : std::conditional_t(A::value), conjunction, A> +{}; + +/// Implementation of \ref std::conjunction_v. +template +constexpr bool conjunction_v = conjunction::value; + +/// Implementation of \ref std::disjunction. +template +struct disjunction : std::false_type +{}; +template +struct disjunction : A +{}; +template +struct disjunction : std::conditional_t(A::value), A, disjunction> +{}; + +/// Implementation of \ref std::disjunction_v. +template +constexpr bool disjunction_v = disjunction::value; + +// --------------------------------------------------------------------------------------------------------------------- + +static_assert(conjunction_v<> == true, ""); +static_assert(conjunction_v == true, ""); +static_assert(conjunction_v == false, ""); +static_assert(conjunction_v == true, ""); +static_assert(conjunction_v == false, ""); +static_assert(conjunction_v == false, ""); +static_assert(conjunction_v == false, ""); + +static_assert(disjunction_v<> == false, ""); +static_assert(disjunction_v == true, ""); +static_assert(disjunction_v == false, ""); +static_assert(disjunction_v == true, ""); +static_assert(disjunction_v == true, ""); +static_assert(disjunction_v == true, ""); +static_assert(disjunction_v == false, ""); + } // namespace pf17 } // namespace cetl