How do I properly define a default return value of a function that is an argument of another function?
Let's say I have a function like this:
bool x( ... , std::function<bool( ... )> func ) { ... ; return func( ... ); }
I would like x to return true if it's called without the last argument.
You can specify a lambda as the default value of func, e.g.
bool x( ... , std::function<bool( ... )> func = []( ... ) { return true; } ) { ... ; return func( ... ); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With