C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Review Request: Proposal Ternary Right Fold Expression (P1012)
From: Frank Zingsheim (f.zingsheim_at_[hidden])
Date: 2020-11-09 14:19:09


Hello Barry and Jason

I was confused by the `template` keyword in front of the `for...` which
I did not find in the proposal.

I have worked in the usage of the `for...` in on the working branch
`progress` of my proposal (see https://github.com/zingsheim/ProposalTer
naryFold/blob/9b8fdf1/ProposalTernaryFold.md#a-expansion-statements-
for-p1306r1-6). Can you check if I understood the usage of `for...`
correctly, or if there is maybe a more compact formulation possible
with the `for...` proposal.

        Frank

>
> It's there implicitly. The way `for...` works is by unrolling the
> range-based `for` loop. The way it unrolls the loop is *specifically*
> defined to create a new variable for each iteration, copied from the
> definition in the `for...` statement. The variable is never
> overwritten by each iteration; you're getting a new variable each
> time; it just happens to have the same name.
>
> This allows each iteration variable to have a different type (by
> specifying `auto` or another placeholder), but this *also* allows
> that
> variable to be declared `constexpr`, since you're never modifying it.
>


STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups