I’m having problems trying to create the following lambda function:
const auto var x = [&y]() -> /*???*/ {
if (y == type1) {
return some_type_1;
} else if (y == type2) {
return some_type_2;
} else // ...
I know I cannot use auto as return type. But how can I do it in another way?
Thanks!
If
some_type_1andsome_type_2have a common type, write:Equivalently, you can use a ternary expression: