Can I use variable templates without using template parameters as function parameters?
When I use them, it compiles:
#include <iostream> using namespace std; template<class First> void print(First first) { cout << 1 << endl; } template<class First, class ... Rest> void print(First first, Rest ...rest) { cout << 1 << endl; print<Rest...>(rest...); } int main() { print<int,int,int>(1,2,3); }
But when I do not use them, it does not compile and does not complain about ambiguity:
#include <iostream> using namespace std; template<class First> void print() { cout << 1 << endl; } template<class First, class ... Rest> void print() { cout << 1 << endl; print<Rest...>(); } int main() { print<int,int,int>(); }
Unfortunately, the classes that I want to provide as template parameters are not real (they have static functions that are called inside the template function). Is there any way to do this?
Heinzi
source share