C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Initial draft for C++: Uniform Initialization for Multiple Variables

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sat, 26 Oct 2024 00:41:55 +0300
On Mon, 12 Aug 2024 at 14:45, Amber Bhardwaj via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> Hello CppCommunity,
>
> My name is Amber Bhardwaj. It's been almost a decade since I started using C++. I got an idea that I want to present in front of this cpp community. I am not sure how good this idea is for others! But I feel this feature should be present so kindly review it and suggestions are most welcome.
>
> 1. Problem Statement
>
> C++ currently requires separate lines for declaring and initializing multiple variables of the same type. This can become verbose and cumbersome, especially for simple cases where all variables share the same value.
>
> 2. Proposed Solution
>
> Introduce a new syntax for uniform initialization of multiple variables within curly braces:
>>
>> type {var1, var2, ..., varn} = value;

type{var1, var2, ..., varn} always means initialization in C++, and is
always an expression, never a declaration. The very last thing
we want to do is open the door to it possibly also meaning a declaration.

Received on 2024-10-25 21:42:10