|
Boost : |
Subject: Re: [boost] Variant2 review
From: Gavin Lambert (boost_at_[hidden])
Date: 2019-04-08 00:56:19
On 8/04/2019 05:03, Peter Dimov wrote:
> Phil Endecott wrote:
>> - I would love to have some way to get a warning or error if the
>> double storage mode had been triggered, or to disable that mode (with
>> an error).
>
> I was thinking of addressing this by adding either
>
> Â Â static constexpr bool variant<T...>::is_single_buffered();
>
> or
>
> Â Â static constexpr bool variant<T...>::is_double_buffered();
>
> (not sure which spelling is better), so that you can static_assert that
> your variants are never double-buffered.
Something like this would definitely be nice.
Especially when something as simple as accidentally omitting "noexcept"
can cause a significant behavioural and storage size change, it's great
to be able to tell the compiler that this was unintended.
(Of course, as I've said before I would have preferred that this choice
was made by providing two different front-end "variant" types -- that
way the assert is already inside the library and the user can't forget
to make it.)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk