Let's say, I have the following piece of code:
#include <iostream>
template <size_t... Is> struct E {};
template <typename... Ts, size_t... Is>
void func (E<Is...>, Ts...) {std::cout << __PRETTY_FUNCTION__ << std::endl;}
int main()
{
func(E<1,2,3>{}, 1, 'a');
}
It works perfectly fine and produces
void func(E<Is ...>, Ts ...) [with Ts = {int, char}; long unsigned int ...Is = {1, 2, 3}]
However, if I replace func
call with func<int, char, 1, 2, 3>(E<1,2,3>{}, 1, 'a');
, it will cause the compilation error, i.e.,
template argument deduction/substitution failed
Why compiler forbids the explicit specification of multiple parameter packs?