C++ Logo

std-proposals

Advanced search

Re: [std-proposals] for ( repeat_count )

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Mon, 23 Oct 2023 16:19:57 +0200
pon., 23 paź 2023 o 15:23 Tom Honermann via Std-Proposals
<std-proposals_at_[hidden]> napisał(a):
>
> On 10/23/23 5:18 AM, Frederick Virchanza Gotham via Std-Proposals wrote:
> > What if the following:
> >
> > for ( usigned i = 0u; i < len; ++i ) *p++ = Get();
> >
> > Could be written as simply:
> >
> > for ( len ) *p++ = Get();
>
> Why?
>
> It is pretty rare that I need a (finite) loop and not need the loop
> index in the loop body.
>
> Tom.

We have it already, operator `-->`:
```
while(len --> 0) *p++ = Get();
```
:>

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

Received on 2023-10-23 14:20:11