|
Boost : |
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2019-06-27 16:47:22
On 6/27/19 7:32 PM, Robert Ramey via Boost wrote:
> On 6/27/19 8:43 AM, Andrey Semashev via Boost wrote:
> - From the caller's perspective, a noexcept function will never throw.
>>
>>> In anycase I should have phrased the above as:
>>>
>>> Is swap guaranteed to succeed?
>>
>> In general, no. It is only guaranteed to succeed if it is noexcept.
>> See above when it is noexcept.
>
> A... - I'm still confused. How can one say that swap is guaranteed to
> succeed when it can result in calling terminate()?
First, people normally don't write noexcept functions knowing they might
throw. Meaning that the call to terminate() is equivalent to a bug.
Second, your code after a noexcept swap() returns will not be run if
terminate() gets called. Meaning that the code is guaranteed to only
operate when swap() successfully returned.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk