I want to default a lambda argument in a template function but it fails to compile. What am I missing?
template <typename F>
void foo(
F f = [](){
std::cout << "Hello!\n";
}
) {
f();
}
int main() {
foo(); // 1. does not compile
foo([](){ // 2. this is ok
std::cout << "Hello!\n";
});
}