C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Array Index in Range-based For Loops

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Fri, 3 Mar 2023 00:12:10 +0200
On Fri, 3 Mar 2023 at 00:01, Thiago Macieira via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> On Thursday, 2 March 2023 13:47:14 PST Sebastian Wittmeier via Std-Proposals
> wrote:
> > for (int i = 0; auto const &e : some_container)
> > DoSomeProcessing(e, i++);
>
> Or:
>
> int i = 0;
> for (auto const &e : some_container)
> DoSomeProcessing(e, i++);
>
> which is already possible.

The approach suggested by Sebastian is also "already possible", since C++20.

Received on 2023-03-02 22:12:23