Re:C++20 Idioms for Parameter Packs
by angiosperm on Wednesday February 28, 2024 @04:57PM
(#39543989)
Why does the
construct work, when we needed same_as<char>?
[ Parent
| on HN ]
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.