C++ Logo


Advanced search

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

From: Desmond Gold Bongcawel <desmondbongcawel922_at_[hidden]>
Date: Sun, 14 Nov 2021 15:10:02 +0800
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:10:15