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.
您可以将lambda指定为func
的默认值,例如
bool x( ... , std::function<bool( ... )> func = []( ... ) { return true; } ) { ... ; return func( ... ); }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.