Boost logo

Boost :

Subject: Re: [boost] [variant2] Review of Variant2
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2019-04-16 22:17:44


On 4/17/19 1:06 AM, Steven Watanabe via Boost wrote:
> AMDG
>
> On 4/14/19 10:05 AM, Peter Dimov via Boost wrote:
>> Andrey Semashev wrote:
>>
>>> Beside these mandatory requests, I'd be very interested if Peter
>>> presented an updated variant proposal, which doesn't create values out
>>> of thin air except if it's monostate.
>>
>> Since mostly everyone has objected to it - Bjorn has it as an acceptance
>> condition - I'll remove the "default construct a suitable alternative"
>> fallback.
>>
>> I'm not yet sure about the monostate special case, as it becomes even
>> more special now. I tend towards removing that too, and just offering
>> the strong guarantee.
>>
>
> What about this: Only consider default constructing the
> first type, not any type in the list. This should be
> much less surprising, because it creates the same state
> as a default-constructed variant.

I think, that's not much better than default-constructing a random
value. There would be no way to prohibit such behavior. OTOH, monostate
is a clear marker indicating that such behavior is allowed.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk