Raku, Ruby, and Perl have a redo instruction to do it as you stated.

 

https://docs.raku.org/language/control?utm_source=chatgpt.com#Control_flow
 

-----Ursprüngliche Nachricht-----
Von: scbd Gm via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Mo 16.11.2026 17:41
Betreff: [std-proposals] Discussion: A proposed repeat statement for C++
An: std-proposals@lists.isocpp.org;
CC: scbd Gm <scnd2908gm@gmail.com>;

Hello everyone,

I'm interested in proposing a new C++ control-flow statement called repeat.

The motivation is to provide a dedicated way to restart the current loop iteration immediately, without executing the remaining statements or the loop's increment expression.

For example:

int x = 0;  for (int i = 0; i < 5; i++) {     x++;      cout << "Hello\n";      if (x != 2)         repeat; }

My proposed semantics are:

  1. Restart the innermost enclosing loop body.

  2. Skip the remaining statements of the current iteration.

  3. Do not execute the loop's increment expression.

  4. Destroy and reinitialize local objects belonging to the loop body's scope.

  5. Preserve variables declared outside the loop body.

  6. Support for, while, and do-while loops.

I believe this could provide a cleaner and more expressive alternative to certain uses of goto and nested loops.

I would appreciate feedback on:

This is an early-stage idea, and I would appreciate constructive criticism.

Thank you!

-- 
 Std-Proposals mailing list
 Std-Proposals@lists.isocpp.org
 https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals