Boost logo

Boost :

From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2023-10-15 17:01:54


On 10/9/23 19:27, Andrey Semashev wrote:
> On 10/9/23 18:33, Peter Dimov via Boost wrote:
>> Andrey Semashev wrote:
>>> Source:
>>>
>>> https://github.com/Lastique/scope
>>>
>>> Docs:
>>>
>>> https://lastique.github.io/scope/libs/scope/doc/html/index.html
>>
>> Question:

[...]

>> Also, wouldn't it be better if scope_exit took a second parameter
>> C defaulting to "always" instead of having scope_check?
>
> Do you mean to effectively rename scope_check to scope_exit, and add a
> default predicate that always returns true?
>
> I suppose, it is possible, although currently scope_exit is a bit more
> lightweight than scope_check. The latter is more complicated because the
> implementation should be prepared for the failure condition predicate
> constructor to throw. Perhaps, that is a good idea, if that extra
> overhead is not considered as a problem.

I have now merged scope_check into scope_exit, as you suggested. There
is already a lightweight scope_final guard, so making scope_exit more
feature-rich seemed like a good idea. Thanks for the suggestion.

Also, for anyone interested, I have created a single-header version of
the library that is compatible with godbolt.org:

https://godbolt.org/z/6rvhnTrvn

Feel free to try it online.

PS: The single-header version is not part of the library, as proposed
for inclusion into Boost. It's just to simplify the review process.


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