Boost logo

Boost :

Subject: Re: [boost] Another variant type (was: [peer review queue tardiness] [was Cleaning out the Boost review queue] Review Queue mem
From: pfultz2 (pfultz2_at_[hidden])
Date: 2015-04-14 13:39:48

> You can't in the general case because you have to call the constructor of
> the appropriate internal type. You can't placement new, so you have to do
> it via a member initializer, so which internal type's constructor do you
> call?

I see. You have to decide the member initialization based on a runtime
Thats just not possible.

However, the more I think about it, I don't think a constexpr union type
much sense. The type is known at compile-time. Instead a constexpr sum type
would just store the type and the possible types:

    template<class T, class... Choices>
    class constexpr_sum_type : T

Then the `Choices...` types can be used in the visitor to enforce compile
checking of all the branches. Perhaps, some generalized unpacking mechanism
could help normalize the usage of constexpr and non-constexpr sum types.


View this message in context:
Sent from the Boost - Dev mailing list archive at

Boost list run by bdawes at, gregod at, cpdaniel at, john at