Is there any specific cases you cannot correctly do with std::conjunction
/std::disjunction
and not using the more \"fundamental\" (i.e. language featur
std::conjunction
short-circuits ::value
instantiation, while the fold expression doesn't. This means that, given:
template
struct valid_except_void : std::false_type { };
template <>
struct valid_except_void { };
The following will compile:
template
constexpr auto test = std::conjunction_v...>;
constexpr auto inst = test;
But the following won't:
template
constexpr auto test = (valid_except_void::value && ...);
constexpr auto inst = test;
live example on godbolt.org
From cppreference:
Conjunction is short-circuiting: if there is a template type argument
Bi
withbool(Bi::value) == false
, then instantiatingconjunction
does not require the instantiation of::value Bj::value
forj > i
.