|
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
value.
Thats just not possible.
However, the more I think about it, I don't think a constexpr union type
makes
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
time
checking of all the branches. Perhaps, some generalized unpacking mechanism
could help normalize the usage of constexpr and non-constexpr sum types.
Paul
-- View this message in context: http://boost.2283326.n4.nabble.com/Another-variant-type-was-peer-review-queue-tardiness-was-Cleaning-out-the-Boost-review-queue-Review--tp4674046p4674450.html Sent from the Boost - Dev mailing list archive at Nabble.com.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk