2 ms·
I think the closest you can get is something like: class odd {...}; class even {...}; std::variant<odd, even> p(int a) { if (a&1) return o
by KayEss 7y ago
I think the closest you can get is something like:
class odd {...};
class even {...};
std::variant<odd, even> p(int a) {
if (a&1) return odd{a};
else return even{a};
}
Now which of `even` or `odd` you get is based on the value of `a`.