Subject: Re: [boost] [outcome] Exception safety guarantees
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2017-05-27 17:45:12
2017-05-27 19:25 GMT+02:00 Peter Dimov via Boost <boost_at_[hidden]>:
> Andrzej Krzemienski wrote:
> How come? I thought bsic guarantee menas I just should be able to safely
>> destroy it without UB or resource leaks, and perhaps to reset it. How does
>> the above not meet these guarantees?
> No. Basic means you can safely use the object. It's in an unspecified
> state, but it's usable. Same as move - unspecified, but valid.
> 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. You need to first inspect `o` to see
what you can safely do with it.
If you get a std::variant<> just after the throw, you can inspect it with
valueless_by_exception() and then you know the safe subset of operations is
assignment or destructor. valueless_by_exception() is a valid state, even
though you cannot set an object to this state easily.
Am I wrong here?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk