C++ Logo

std-proposals

Advanced search

Re: [std-proposals] "once" keyword

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Wed, 24 May 2023 09:49:50 -0400
On Wed, May 24, 2023 at 9:18 AM Giuseppe D'Angelo via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> On 24/05/2023 15:02, language.lawyer--- via Std-Proposals wrote:
> > if (Failed(Condition0)) goto skip_Code_to_execute;
> > if (Failed(Condition1)) goto skip_Code_to_execute;
> >
> > Code_to_execute;
> >
> > skip_Code_to_execute:
> > ...
>
> 1) If "Code_to_execute" contains declaration with non-vacuous
> initialization, then this is ill formed as per:
> https://eel.is/c++draft/stmt.dcl#2


Sure, but wrap `Code_to_execute` in a pair of curly braces and you're all
set.

Anyway, isn't this just asking for a macro `#define ONCE(...) do {
__VA_ARG__ } while (0);` and that such a macro should go into the
International Standard? No thanks.

David Brown wrote:
> I think a better idea here would be to propose allowing "break" inside an
"if" statement.

As in `if (x > 5) break;`? I think you should rethink that idea. ;)

–Arthur

Received on 2023-05-24 13:50:04