Date: Wed, 13 Aug 2025 21:50:47 -0700
> On Aug 13, 2025, at 9:41 PM, 叶易安 via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> C++26 `static reflection` proposal wanna to bring a syntax called `template for`. We know that C++17 introduced one similar thing called `if constexpr`, So why not make the style unified and call it `for constexpr` ?
>
template for is not a constexpr, so this would be incorrect.
`if constexpr` is an if that is guaranteed to be evaluated at compile time, template for is just a for loop where each “iteration” may have a different type. The type unrolling occurs at compile time, but the body of the for loop is not evaluated at compile time, which is what constexpr would be saying.
—Oliver
>
> C++26 `static reflection` proposal wanna to bring a syntax called `template for`. We know that C++17 introduced one similar thing called `if constexpr`, So why not make the style unified and call it `for constexpr` ?
>
template for is not a constexpr, so this would be incorrect.
`if constexpr` is an if that is guaranteed to be evaluated at compile time, template for is just a for loop where each “iteration” may have a different type. The type unrolling occurs at compile time, but the body of the for loop is not evaluated at compile time, which is what constexpr would be saying.
—Oliver
Received on 2025-08-14 04:50:59