Consider the following code
template void foo(const T& t = []() {}) {
// implementation here
}
void bar() {
foo([&
The compiler uses the arguments passed to deduce the template type. If there's no arguments, then how would the compiler be able to deduce the template type?
You can use overloading instead of default arguments here.
The overloaded non-argument function can simply call the function with the "default" argument:
template void foo(const T& t) {
// implementation here
}
template void foo() {
foo([]() {});
}