C++ Logo

sg20

Advanced search

Re: [SG20] A draft paper to fix the range-based for loop to make it teachable

From: Balog Pal <pasa_at_[hidden]>
Date: Tue, 10 Nov 2020 11:48:41 +0100
On 11/10/2020 10:41 AM, Yehezkel Bernat via SG20 wrote:

> 3. IMHO, the best and simplest solution is to use
> std::ranges::for_each, because it holds the temporary till the end of
> the loop due to the function call semantics.

There's light and day difference between the simple for() form with the
direct body and access to break, continue compared to forcing a lambda.
for_each may be considered as a workaround but by no means can count as
best or simplest solution -- especially for an artificial problem
planted into the language.

I absolutely want the language to evolve by fixing core facilities to
just work along original intended semantics without gotchas and chapters
to teach.

Received on 2020-11-10 04:48:53