>>101911460
int foo( std::function< int( bool, char ) > callback )
{
bool a = true;
char b = 'f';
return callback( a, b );
}
foo( []( bool a, char b ){ return 1; }); // fine
foo( [this]( bool a, char b ){ return 2; }); // fine
foo( [this, that]( bool a, char b ){ return 3; }); // fine
foo( [&]( bool a, char b ){ return 4; }); // fine
I think in c++23 you can even pass lambdas by value directly without std::function using
int foo( auto callback );