Skip to content

Commit

Permalink
fmtlib#2954: Provide std::conjunction and std::disjunction substitutes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dani-Hub committed Jul 2, 2022
1 parent c12b4c0 commit 5eeeb31
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions include/fmt/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,32 @@ template <typename T> using type_identity_t = typename type_identity<T>::type;
template <typename T>
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 {
constexpr monostate() {}
};
Expand Down

0 comments on commit 5eeeb31

Please sign in to comment.