Boost logo

Boost :

From: Eric Friedman (ebf_at_[hidden])
Date: 2002-08-08 04:59:47


>From David Abrahams:

> From "Eric Friedman" <ebf_at_[hidden]>
[snip]
> > * Is it a major obstacle that Boost.Variant will not offer
> > exception-safe assign
> > or swap unless externally wrapped with the pimpl idiom? Should
> > boost::fast_variant
> > and boost::safe_variant be introduced to encapsulate yet allow
> > choice in this issue?
>
> Wait!
>
> ***** There's nothing unsafe about the basic guarantee. *****
>
> The strong guarantee is not the holy grail of exception-safety, as
many
> people seem to think. It's just a useful behavior to distinguish.
> There's no reason to resort to heroics just to achieve it.

Well, having the strong guarantee does make variant's use much, much
nicer.

Now, in the process of removing the undefined behavior from swap and
assign, I've had to reintroduce the notion of an empty variant (namely,
an empty variant is one that has only "partly" made it through an assign
or a swap).

> > * Any ideas out there as to how to make variant::operator= and
> > variant::swap "as safe
> > as possible," yet still efficient, even if we can't guarantee
> > strong exception-safety?
>
> Sure, just do the straightforward assignment and swap provided by the
> underlying type.

Not quite that straightforward <g>, but the changes have been uploaded
to
the sandbox. (See boost/variant.hpp for the bulk of the changes.)

- Eric


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