C++ Logo

std-proposals

Advanced search

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

From: Sebastian Wittmeier <wittmeier_at_[hidden]>
Date: Sat, 26 Oct 2024 11:38:00 +0200
Perhaps instead of a new std::rep std::ranges::views::repeat can be made usable with structured bindings?   Probably with https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1061r5.html   -----Ursprüngliche Nachricht----- Von:Ville Voutilainen via Std-Proposals <std-proposals_at_[hidden]> Gesendet:Fr 25.10.2024 23:42 Betreff:Re: [std-proposals] Initial draft for C++: Uniform Initialization for Multiple Variables An:std-proposals_at_[hidden]; CC:Ville Voutilainen <ville.voutilainen_at_[hidden]>; 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. -- Std-Proposals mailing list Std-Proposals_at_[hidden] https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2024-10-26 09:38:19