C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Multiple init in if-statements

From: Justin Cooke <jgc_at_[hidden]>
Date: Wed, 30 Apr 2025 11:12:11 +0200
On 29 Apr 2025 at 19:43, Aurelien Cassagnes via Std-Proposals wrote:

>
> There is a fairly arbitrary (unless I missed an important argument) limitation on initialization clause
> for if statements.
>
> - I have that
>   if (auto it = vec.begin(); it != vec.end()) {
>
> - I want this
>   if (auto it = vec.begin() /*and*/ auto itt = ++vec.begin(); it != vec.end() && it != itt) {
>
>
> Is there any current proposal that aims to lift that restriction ?


Yes. P2608 proposes that in all cases where an init-statement is allowed or required, mutliple init-statements should be allowed.  It is not limited to if statements.

https://open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2608r0.html

  

Received on 2025-04-30 09:12:15