Allow code like:
for (int i : std::views::iota(1, 10))
std::cout << i << ' ';
Other versions you can create helpers in a similar way.This example requires to include a header instead of being an intrinsic property of the for loop. Also is way more verbose than for (int i = 1 : 10) my hope is to make things simpler and easier to read without losing functionality.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);True, but isn't creating a tuple to just decompose it excessively verbose? Not to mention the need to include a header;
also we lose the expressivity of separating each declaration, on my opinion each part separated on different declarations implies intentionality, also more control on the resulting type, i.e:template <auto size>
void lcase(const char (&in)[size], char (&out)[size])
{
for (const char *b = in; const char *const e = in + size; char *o = out; b != e; ++b, ++o) // Three different explicit types
*o = std::tolower(*b);
}Missatge de Jonathan Wakely <cxx@kayari.org> del dia dl., 10 de febr. 2025 a les 15:31:On Mon, 10 Feb 2025 at 14:18, Pau Miquel Montequi Hernandez via Std-Proposals <std-proposals@lists.isocpp.org> 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);
}
--Pablo Miguel Montequi Hernández.