For this simplified piece of code I'm getting following error:
error: too few arguments to function std::cout << f();
int g(int a = 2, int b = 1)
{
return a + b;
}
template<class Func>
void generic(Func f)
{
std::cout << f();
}
int main()
{
generic(g);
}
I cannot clue the reason for why the default parameters of function f are not passing into a function generic. It behaves like f doesn't have any default parameters ...
What's wrong there?
How do I forward default parameters correctly?
aandbare function parameters. These parameters have default arguments of 2 and 1, rsp. Soais a parameter, and the value ofaat run time is the argument.