Recurvise call C++ template function with Variable template
void int void foo()
{
}
template <typename T, typename ...U> void foo()
{
foo<U...>();
}
int main()
{
foo<int, char, int>();
return 0;
}
The compile meesage such as:
error C2672: 'foo': no matching overloaded function found note: see reference to function template instantiation 'void foo(void)' being compiled note: see reference to function template instantiation 'void foo(void)' being compiled note: see reference to function template instantiation 'void foo(void)' being compiled error C2783: 'void foo(void)': could not deduce template argument for 'T' note: see declaration of 'foo'
I declare the void foo(void), Why the error occured? complier can match template void foo(), but can't match void foo(void)
foo<U...>()
require a specialization to stop the recursion.void foo()
is not a specialization of the template. – qduyang