Date: Sat, 10 Jun 2023 10:38:47 -0400
On Sat, Jun 10, 2023 at 10:27 AM Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> Sometimes I have code like this:
>
> void Func(void)
> {
> OnScopeExit dummy( [](){ ::close(global_fd); } );
>
> // Do more stuff here
> }
>
> If I later amend this function so that further down there's another
> 'OnScopeExit', then I have to name the second one "dummy1", and the
> third one "dummy2" and so on.
>
See "The Auto() macro" for a way to do this without dummy names and with
less visual noise.
https://quuxplusone.github.io/blog/2018/08/11/the-auto-macro/
–Arthur
Std-Proposals <std-proposals_at_[hidden]> wrote:
> Sometimes I have code like this:
>
> void Func(void)
> {
> OnScopeExit dummy( [](){ ::close(global_fd); } );
>
> // Do more stuff here
> }
>
> If I later amend this function so that further down there's another
> 'OnScopeExit', then I have to name the second one "dummy1", and the
> third one "dummy2" and so on.
>
See "The Auto() macro" for a way to do this without dummy names and with
less visual noise.
https://quuxplusone.github.io/blog/2018/08/11/the-auto-macro/
–Arthur
Received on 2023-06-10 14:39:01