#pragma once #include #include "types.h" namespace cppmp { namespace __impl { /* eval_if_c_impl */ template class E, typename... A> struct eval_if_impl; } /* enable_if */ /** * @brief Defines T as ::type if B is true, otherwise the resulting type is empty. */ template struct enable_if : public std::enable_if { }; /** * @brief Resulting type is T if B is true. If B is false the resulting type is invalid. */ template using enable_if_t = typename enable_if::type; /* conditional/if */ /** * @brief Defines T as ::type if B is true, F otherwise. */ template struct conditional : public std::conditional { }; /** * @brief Evaluates to T if B is true, to F otherwise. */ template using conditional_t = typename conditional::type; /** * @brief Same as conditional. */ template struct if_ : public conditional { }; /** * @brief Same as conditional_t. */ template using if_t = typename if_::type; /* eval_if */ /** * @brief Defines T as ::type if B is true, evaluates E otherwise. */ template class E, typename... A> struct eval_if : public __impl::eval_if_impl { }; /** * @brief Evaluates to T if B is true, to E otherwise. */ template class E, typename... A> using eval_if_t = typename eval_if::type; /* conjunction/and */ #if __cplusplus >= 201703L /** * @brief Evaluates to true_t if all passed arguments are also true_t. */ template struct conjunction : public std::conjunction { }; /** * @brief It to true if all passed arguments are also true_t. */ template constexpr decltype(auto) conjunction_v = conjunction::value; /** * @brief Same as conjunction. */ template struct and_ : public conjunction { }; /** * @brief Same as conjunction_v. */ template constexpr decltype(auto) and_v = conjunction::value; #endif /* disjunction/or */ #if __cplusplus >= 201703L /** * @brief Evaluates to true_t if at least one passed arguments is true_t. */ template struct disjunction : public std::disjunction { }; /** * @brief Is true if at least one passed arguments is true_t. */ template constexpr decltype(auto) disjunction_v = disjunction::value; /** * @brief Same as disjunction. */ template struct or_ : public disjunction { }; /** * @brief Same as disjunction_v. */ template constexpr decltype(auto) or_v = disjunction::value; #endif } #include "conditionals.inl"