To set a std::function variable to a lambda function with default argument I can use auto
as in:
auto foo = [](int x = 10){cout << x <<
In C++20 you will be able to do this:
struct foo {
decltype([](int a = 10){std::cout << a << '\n';}) my_lambda{};
};
int main() {
foo f;
f.my_lambda();
f.my_lambda(5);
}
It does look a bit strange, but it works just fine.
What makes this possible is the ability to use lambdas in unevaluated contexts and default construct stateless lambdas.