Boost logo

Boost :

Subject: Re: [boost] [variant2] documentation request
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2019-03-02 18:08:32


> It so happens that the strong guarantee is unachievable with variant
> (without too much double buffering.) You can either have basic, or
> noexcept.

You surprise me, given this is a design capable of double buffering.

For a variant2<A, B>, where both A and B have throwing move constructors
and assignment, surely if the variant has state A in buffer1, setting it
to state B would use buffer2. If B throws during move, we simply don't
change the currently selected buffer to buffer2. The variant's A state
remains untouched i.e. strong guarantee.

I guess you haven't written out anywhere how and when the double
buffering comes into play. I would have assumed that as soon as all the
types do not have all noexcept moves, the double buffer implementation
kicks in. That certainly was the design that Anthony was demonstrating a
few years back, unless my memory is faulty.

If this isn't the case, that needs to be documented and explained,
because I don't see the point of double buffering unless you get the
strong guarantee.

Niall


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