C++ Logo

std-proposals

Advanced search

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

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Mon, 12 Aug 2024 12:37:13 -0400
On Mon, Aug 12, 2024 at 7:45 AM 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.

First, C++ doesn't require using separate lines. It only requires it
if you want to initialize them to the same value. And even then, it
doesn't require separate lines:

int first = 5, second = 5, third = 5;

There is repetition, but your issue only applies when initializing
them all to the same value. Is that case *really* common enough to be
worth a language change?

That's what your proposal needs to convince people of.

Received on 2024-08-12 16:37:26