Boost logo

Boost :

Subject: Re: [boost] [outcome] Exception safety guarantees
From: Peter Dimov (lists_at_[hidden])
Date: 2017-05-27 18:56:00

Andrzej Krzemienski wrote:
> > Destroy-only is a completely different animal.
> What? How is that different? Surely, when a basic-guarantee operation
> failed on object `o`, you cannot safely use all operations on `o` that you
> were allowed to use before the throw.

Yes, you can. That's the whole point. It's as if someone handed you a valid
object `o`. You don't know what's inside, but you know that it's not
destroy-only. It has some value, you just don't know what it is.

Sure, you can abide by the letter of the basic guarantee while trampling all
over its spirit by littering all member functions with a "!valueless()"
precondition, but this doesn't change much.

In other words, under basic guarantee, r.has_value() returns true or false,
under destroy-only it crashes.

In yet other words, under basic guarantee, you in general have wide contract
functions, under destroy-only, you never do (except for the destructor and
possibly assignment.)

Boost list run by bdawes at, gregod at, cpdaniel at, john at