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 <<
One way you could solve this would be to wrap your std::function
in a functor object which implements the default arguments for you:
struct MyFunc
{
void operator()(int x = 10) { f(x); }
std::function f;
};
struct Bar
{
MyFunc foo = {[](int x){std::cout << x << "\n";}};
};
int main() {
Bar bar;
bar.foo();
}