C++ Logo

std-discussion

Advanced search

Re: Some feedback on scope guards

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Sun, 16 Apr 2023 17:25:31 -0300
On Sun, 16 Apr 2023, 17:17 Ville Voutilainen, <ville.voutilainen_at_[hidden]>
wrote:

> 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.
>

Yes, that sounds reasonable to me.

>

Received on 2023-04-16 20:25:46