If this is possible, one can index into a variadic template parameter pack without recursion. However, GCC is refusing to pick up my partial specialization here:
<
The spec says at 14.8.2.5p9
If P has a form that contains
<T>
or<i>
, then each argumentPi
of the respective template argument listP
is compared with the corresponding argumentAi
of the corresponding template argument list ofA
. If the template argument list ofP
contains a pack expansion that is not the last template argument, the entire template argument list is a non-deduced context.
Your typelist<T>
unfortunately matches that pattern.
AFAICT, the rules for matching partial specializations are the same as the rules type deduction of function parameters. And §14.8.2.1/1 says the following:
For a function parameter pack that occurs at the end of the parameter-declaration-list, the type
A
of each remaining argument of the call is compared with the typeP
of the declarator-id of the function parameter pack. Each comparison deduces template arguments for subsequent positions in the template parameter packs expanded by the function parameter pack. For a function parameter pack that does not occur at the end of the parameter-declaration-list, the type of the parameter pack is a non-deduced context.
So the packs TL
and IL
cannot be deduced in this case, and the partial specialization is not picked.