Consider the following minimal example:
#include<cstddef>
template<std::size_t... I>
constexpr auto sum() { return (I + ...); }
template<bool... B>
constexpr auto check() { return (B && ...); }
int main() {
static_assert(6 == sum<1,2,3>(), "!");
// static_assert(0 == sum<>(), "!");
static_assert(check<true, true>(), "!");
static_assert(check<>(), "!");
}
The commented line doesn't compile.
The same applies using *
instead of +
.
The one involving booleans works instead.
Here (working draft) I haven't found mentions about empty parameter packs.
On the other side, here (isocpp) it seems that the default result in the case above is int()
.
What's exactly the expected behavior when mixing fold expressions and an empty parameters pack?