Given a non-variadic function template:
template<class T>
void f(void(t)(T));
And some plain functions:
void f1(int);
void f2(char);
This works:
f(f1);
The type of t
becomes void (*)(int)
.
However, the variadic counterpart:
template<class... T>
void f(void(...t)(T));
// call
f(f1, f2);
does not work. The compilers (gcc & clang) complain about mismatched types void(T)
and void (*)(int)
. See DEMO.
Note that if *
is added explicitly, it works as it should:
template<class... T>
void f(void(*...t)(T));
So, why the non-variadic one can decay the function type while the variadic one cannot?