I'm looking to unroll a variadic template into separate functions used in the conjunction of an if
-statement. Here's an example of what I'm trying to do:
template <typename T, size_t I>
bool bar(const T& param) { return param[I] != 13; }
template <typename T, size_t... ARGS>
void bar(const T& param, const std::index_sequence<ARGS...>&) {
if(bar<ARGS>(param) && ...)
{
cout << "no matches\n";
}
else
{
cout << "matched\n";
}
}
But this gives me the error:
error C3520:
ARGS
: parameter pack must be expanded in this context
I want the line: if(bar<ARGS>(param) && ...)
to unroll to: if(bar<0U>(param) && bar<1U>(param) && bar<2U>(param))
Is there a way I can do this? Or is there an additional adapter that I can use which will accomplish this?