C++ Logo


Advanced search

Re: Labeled `break` and `continue` (usable in `constexpr`)

From: Desmond Gold Bongcawel <desmondbongcawel922_at_[hidden]>
Date: Sun, 14 Nov 2021 15:14:29 +0800
of course, there may be alternatives such as inserting nested loops inside
lambda, or creating a flag, but this feature is more intuitive and
straightforward. If this is accepted, then goto can finally rest in peace.

On Sun, Nov 14, 2021 at 3:10 PM Desmond Gold Bongcawel <
desmondbongcawel922_at_[hidden]> wrote:

> Labeled breaks may be proposed a long time ago (if it's true).
> For me, constexpr goto may have benefits but it still has potential issues
> at both runtime and compile-time depending on when it is invoked.
> Since labels are allowed in constexpr but gotos aren't, labels are left
> unused (C++23). To bring the purpose for labels in constexpr context,
> labeled control statements are proposed. It can also be used at runtime
> superseding part of goto's purpose.
> This proposal brings the introduction of labeled control statements, and
> also breaking and continuing loops / switches corresponding to their labels.
> It has the same semantics as java's labeled breaks, continues, but there
> is one addition, switch statements can have a label attached to it. (but it
> disallows the usage of labeled continue on current switch's label).

Received on 2021-11-14 01:14:39