Hacker News new | ask | show | jobs
by planede 848 days ago
You don't need recursion, but you do need a template, AFAIK.

https://godbolt.org/z/o53o53W5r

1 comments

Why does the

  <size_t ...Idxs>
construct work, when we needed same_as<char>?
Context. I assume you mean something like `void foo(size_t ...Idxs)`, which indeed doesn't work. It can't work, as nothing indicates that this would be a template, and it should be at least templated on the size of the pack.

<size_t ...Idxs> works because it introduces a pack that is a template parameter, so it naturally gets templated on the size of the pack (as well as on the values).

I guess an other historical issue for the grammar is that without the parameter name, `void foo(size_t ...)` is already valid grammar, and is equivalent to `void foo(size_t, ...)`, a C-style variadic.