#2954: Provide std::conjunction and std::disjunction substitutes
This commit is contained in:
parent
c12b4c0cf1
commit
5eeeb317fc
@ -292,6 +292,32 @@ template <typename T> using type_identity_t = typename type_identity<T>::type;
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
using underlying_t = typename std::underlying_type<T>::type;
|
using underlying_t = typename std::underlying_type<T>::type;
|
||||||
|
|
||||||
|
template <typename...>
|
||||||
|
struct disjunction;
|
||||||
|
template <>
|
||||||
|
struct disjunction<> : std::false_type {};
|
||||||
|
template <typename P>
|
||||||
|
struct disjunction<P> : P {};
|
||||||
|
template <typename P1, typename P2>
|
||||||
|
struct disjunction<P1, P2> : std::conditional<P1::value, P1, P2>::type {};
|
||||||
|
template <typename P1, typename P2, typename P3, typename... Pn>
|
||||||
|
struct disjunction<P1, P2, P3, Pn...>
|
||||||
|
: std::conditional<P1::value, P1, disjunction<P2, P3, Pn...>>::type {
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename...>
|
||||||
|
struct conjunction;
|
||||||
|
template <>
|
||||||
|
struct conjunction<> : std::true_type {};
|
||||||
|
template <typename P>
|
||||||
|
struct conjunction<P> : P {};
|
||||||
|
template <typename P1, typename P2>
|
||||||
|
struct conjunction<P1, P2> : std::conditional<P1::value, P2, P1>::type {};
|
||||||
|
template <typename P1, typename P2, typename P3, typename... Pn>
|
||||||
|
struct conjunction<P1, P2, P3, Pn...>
|
||||||
|
: std::conditional<P1::value, conjunction<P2, P3, Pn...>, P1>::type {
|
||||||
|
};
|
||||||
|
|
||||||
struct monostate {
|
struct monostate {
|
||||||
constexpr monostate() {}
|
constexpr monostate() {}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user