Boost logo

Boost :

Subject: Re: [boost] [outcome] comments on Regular ops
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2018-01-22 23:47:29

2018-01-22 23:31 GMT+01:00 Gavin Lambert via Boost <boost_at_[hidden]>:

> The trick with catch-reswap-rethrow assumes that `T` is more likely to
>>> throw while swapping/moving than `EC`, but it might be quite the
>>> opposite.
>>> Also, it is possible that while reswapping, another exception will be
>>> thrown. In general, you cannot guarantee the roll-back, so maybe it would
>>> be cleaner for everyone if you just declared that upon throw from swap,
>>> one
>>> cannot rely on the state of `result`: it should be reset or destroyed.
>> So, don't bother attempting to restore a valid state at all?
>> Does everybody else agree?
> While it's true that EC could throw on swap, it's probably not very likely
> given that EC is most likely to be either error_code (or moral equivalent)
> or a simple enum/int. So that should be reasonably safe in the majority of
> cases.
> Swapping back noexcept(false) T might be more problematic; successful swap
> out is not a guarantee of successful swap back.

So, maybe provide two implementations of swap: one for `EC` with no-throw
swap, and the other for `EC` with throwing swap.

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