I have this simple lambda:
std::variant<int, char> myLambda = []() { // no suitable user-defined conversion from "type" to "std::variant<int, char>" exists
std::variant<int, char> res;
if (true)
{
res = 1;
}
else
{
res = 'c';
}
return res;
};
But it doesn't compile, producing error no suitable user-defined conversion from "type" to "std::variant<int, char>" exists
. What am I doing wrong?