Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2023-04-14 21:26:51


On 4/14/23 13:00, Andrey Semashev wrote:
> On 4/14/23 09:39, Andrzej Krzemienski wrote:
>>
>> niedz., 9 kwi 2023 o 03:11 Andrey Semashev via Boost
>> <boost_at_[hidden] <mailto:boost_at_[hidden]>> napisał(a):
>>
>> Yes, you can manually (de)activate the guard in small and contained
>> cases, but in general I would very much prefer it to work automatically.
>> Otherwise, it quickly becomes a maintenance nightmare that it was
>> supposed to fix.
>>
>> True. Therefore in my code I would contain the code that requires a
>> guard. (In general, I prefer RAII.)
>> But even contained cases need a scope guard.
>>
>> So, the trade-off is this:
>> scope_fail:
>>   - requires no manual deactivate
>>
>> scope_guard with deactivate():
>>   - works uniformly and unsurprisingly in all contexts, including coroutines
>>   - is fast.
>>
>> I would recommend that this trade-off is documented.
>
> Yes, that makes sense. I will update the docs.

Done. I have added a comparison of scope_fail and scope_exit and a
discussion of pros and cons of each.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk