C++ Logo

std-proposals

Advanced search

Re: [std-proposals] for-loops revision (simplification and new syntax)

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Mon, 10 Feb 2025 14:31:34 +0000
On Mon, 10 Feb 2025 at 14:18, Pau Miquel Montequi Hernandez via
Std-Proposals <std-proposals_at_[hidden]> wrote:

>
> More flexible for loop initialization, allowing multiple init statements:
>
>> template <auto size>
>> void lcase(const char (&in)[size], char (&out)[size])
>> {
>> for (auto b = in, e = in + size; auto o = out; b != e; ++b, ++o)
>>
>
You can do this today with a structured binding:

  for (auto [b,e,o] = std::tuple(in, in + size, out); b != e; ++b, ++o)


> *o = std::tolower(*b);
>> }
>
>
>

Received on 2025-02-10 14:31:56