Consider the following code
template void foo(const T& t = []() {}) {
// implementation here
}
void bar() {
foo([&
You are trying to say something that makes no sense. You are asking the compiler to guess T
from your arguments, but then you do not provide any argument.
The following code does compile, and does what you want:
template void foo(const T& t) {
// implementation here
}
template void foo() {
foo([]() {}); // Call actual implementation with empty lambda
}
void bar() {
foo([&](){ /* implementation here */ }); // this compiles
foo(); // this now compiles as well
}