Consider the following code
template void foo(const T& t = []() {}) {
// implementation here
}
void bar() {
foo([&
Consider overloading it directly:
template
void foo(void) {
foo([](){});
}
See CppReference:
Non-deduced contexts
4) A template parameter used in the parameter type of a function parameter that has a default argument that is being used in the call for which argument deduction is being done:
Type template parameter cannot be deduced from the type of a function default argument: template void f(T = 5, T = 7);
void g() { f(1); // OK: calls f
(1, 7) f(); // error: cannot deduce T f (); // OK: calls f (5, 7) }