Hacker News new | ask | show | jobs
by KayEss 2628 days 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`.