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