template <typename T, typename ... Ts>
void foo(T , Ts ... )
{
}
template <typename ... Ts, typename T>
void bar(T , Ts ... )
{
}
int main()
{
foo<int, char>(1, 'c'); // well formed
foo(1, 'c');
// bar<int, char>(1, 'c'); // ill formed
bar(1, 'c');
}
Why does explicitly specializing the template parameter function not work in the second case (bar
)? It's obvious that the reason is that the parameter pack comes first in the argument-list, but still... why?
In the end of the day both cases work fine with implicit deduction. Explicitly specifying the arguments should only make it easier for the compiler.
To the person who flagged it for duplicate, I am not talking about "normal parameters" if anything like that even exists. Also I am not asking whether I can place a parameter pack before a paremeter, I am asking why I cannot explicitly specify the template arguments when pack comes first in the argument-list.