I am trying to instantiate a function table (to emulate switch
)
template<size_t ... N>
int f(std::index_sequence<N...>, int k)
{
static auto f_table = { []() { return N; }... };
auto f = f_table.begin() + k;
assert((*f)() == k);
return (*f)();
}
which fails with error: parameter packs not expanded with ‘...’:
I can get by with an extra wrapper function but why does lambda fail and is there a workaround?