Is there a way to write a function with two templated types;
- taking two arguments, such that
- the second argument is set to a default value if the function is called with only one argument?
The following does not work:
#include <iostream> template <class A, class B> void f (A a, B b = 0) { std::cout << "Hello world!" << std::endl; } int main () { int i; f (i); } In other words, I would like to have a "template-analogy" to
template <class A> void f (A a, int b = 0) { std::cout << "Hello world!" << std::endl; }
f(i,0), then it does.f(0,"something").template <class A> void f (A a);