C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Discussion: A proposed repeat statement for C++

From: Simon Schröder <dr.simon.schroeder_at_[hidden]>
Date: Tue, 17 Nov 2026 07:00:37 +0100


On Nov 16, 2026, at 6:11 PM, Vinnie Falco via Std-Proposals <std-proposals_at_[hidden]> wrote:


On Mon, Nov 16, 2026 at 8:41 AM scbd Gm via Std-Proposals <std-proposals_at_[hidden]> wrote:

int x = 0;

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

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

I might even leave i++ in the loop header and decrement together with continue instead of repeat. We have seen several good examples how to write this rare example.

And to the original suggestion: I don’t see how ‘repeat’ would be any different from ‘continue’ in a ‘while’ or ‘do-while’ loop.

If you want to propose a new keyword you should sift through open source code that it hasn’t been used as a variable (too often). We don’t want to break existing code–especially for such a rare feature.

--
Std-Proposals mailing list
Std-Proposals_at_[hidden]
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2026-11-17 06:00:53