C++ Logo

std-proposals

Advanced search

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

From: Mike Reed <mike.reed10_at_[hidden]>
Date: Mon, 16 Nov 2026 17:53:48 +0000
"it is a clearer way to express intention"

Isn't the intention

for (...)
{
     do
     {
         // some repeated stuff
     } while (<condition>);
     // some non-repeated stuff
}

Except the above is more flexible because I can put stuff before the
repeated do/while, which you can't do with your new repeat language keyword.

Or maybe I have misunderstood what you are trying to achieve. The
example you gave wasn't too helpful for me.

Mike.



On 16/11/2026 17:11, Vinnie Falco via Std-Proposals 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++;
> }
>
>

Received on 2026-11-16 17:53:53