Boost logo

Boost :

Subject: Re: [boost] [outcome] Exception safety guarantees
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-05-28 10:59:05

> I'll ask the same I asked Peter, because I no longer see the value in
> never-empty guarantee.
> If I have two objecte of type variant<A, B, C>, where A, B can throw on
> copy/move, and C is trivial:
> ```
> variant<A, B, C> a = A{}, b = B{};
> try {
> a = b; // throws
> }
> catch(...) {}
> // at this point a holds a C
> ```
> What good does it make to me that I had an A, wanted to assign a B and got
> a C?

Why would you get a C in 'a'?

'a' previously was set to A.

The assignment of 'b' with B state to 'a' failed due to exception.

So the strong never empty guarantee implemented by both Outcome and
Expected means that 'a' still contains its original A untouched and
undamaged. 'b' also contains its B untouched and undamaged, though that
is up to B's copy constructor.


ned Productions Limited Consulting

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