C++ Logo

std-proposals

Advanced search

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

From: Brian Bi <bbi5291_at_[hidden]>
Date: Mon, 16 Nov 2026 14:07:08 -0300
There are two important differences. The most important one is that `break`
is already in the language and we cannot remove it, even if we believe that
it is not useful enough to be added as a new feature.

The other one is that `break` is simply more useful than `repeat`. I've
certainly had situations where I wanted to write `repeat`, but probably 2
orders of magnitude less often than I've used `break`. That's why I said
that `repeat` is "niche" and I'm against adding niche control flow features
to the core language.

On Mon, Nov 16, 2026 at 2:00 PM scbd Gm via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> You can use goto to achieve the behavior of break as well. However, we
> still use break because it provides a clearer and more readable way to
> express our intention.
>
> I see repeat in the same way. Although its behavior can be achieved using
> goto, having a dedicated repeat statement would make the code cleaner,
> more intuitive, and easier to maintain, especially in complex or nested
> loops.
>
> On Mon, Nov 16, 2026 at 10:54 PM Brian Bi via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> I think so. It's equivalent to using `goto` to jump back to the beginning
>> of the loop body.
>>
>> I'm against adding new niche control flow constructs. You can just use
>> `goto`. We have `goto` in the language for a reason, which is that
>> sometimes you need to use it because none of the "more structured" control
>> flow constructs comfortably accommodate the control flow that you want.
>> Excessive use of `goto` is a code smell, but occasional, justified use is
>> not a problem.
>>
>> The main downside of `goto` is that it can't be used during constant
>> evaluation, but I don't think this is a strong enough reason to add new
>> keywords to the core language.
>>
>> On Mon, Nov 16, 2026 at 1:50 PM Anoop Rana via Std-Proposals <
>> std-proposals_at_[hidden]> wrote:
>>
>>> Can this already be achieved by using existing features of the C++
>>> language? If yes, why "repeat" it. If not, list some use cases for this.
>>>
>>> On Mon, 16 Nov 2026, 22:12 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:
>>>>
>>>>> I'm interested in proposing a new C++ control-flow statement called
>>>>> repeat.
>>>>>
>>>> What?
>>>> --
>>>> Std-Proposals mailing list
>>>> Std-Proposals_at_[hidden]
>>>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>>>
>>> --
>>> Std-Proposals mailing list
>>> Std-Proposals_at_[hidden]
>>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>>
>>
>>
>> --
>> *Brian Bi*
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>


-- 
*Brian Bi*

Received on 2026-11-16 17:07:24