Can I suggest a workaround?
Remove the default template argument for function3 (and function4 ):
template<typename F> int function3(F f = [](int i){return 0;}) { return 0; }
You can call it like this:
function3<func1>();
but I think you want you to be able to do this:
function3();
Is not it? Then create another overload of function3 , which is a function, not a template function:
int function3(func1 f = [](int i){return 0;}) { return function3<func1>(f); }
source share