C++ Logo

std-discussion

Advanced search

Re: Some feedback on scope guards

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sun, 16 Apr 2023 23:16:55 +0300
On Sun, 16 Apr 2023 at 22:56, Edward Catmur <ecatmur_at_[hidden]> wrote:

>> >> Perhaps we should entertain a separate scope fail/success type that is
>> >> coroutine-aware, and leave the TS ones
>> >> without that overhead.
>>
>> This.
>
>
> Agreed, but only if the dangers can be made abundantly clear, via documentation, naming, deprecation and/or ill-formedness.

There are, of course, other people who think this is enough of a
reason not to standardize scope_success/fail, and standardize
just scope_exit (and unique_resource). Then, for users who want the
functionality of scope_success/fail, it's presumably
a flick of the wrist away using a lambda capture of
uncaught_exceptions and an if-check of it in the function, or writing
a wrapper
that does that for any callable. I'd rather take that route than
entertain these fears of various dangers, and especially rather
than entertain the suggestions of the language sprouting multiple destructors.

Received on 2023-04-16 20:17:09