C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Fixing some initialization gotchas
From: Barry Revzin (barry.revzin_at_[hidden])
Date: 2019-08-23 09:32:50


On Fri, Aug 23, 2019, 8:21 AM Maciej Cencora via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Yes, I am proposing to make 'auto x{1};' ill formed because such form is
> ambiguous depending on how many elements you pass in braced init list (and
> it differs in C++11).
>
> Fixing the fall-out is trivial (either use 'auto x = 1;' or
> 'std::initializer_list x = { 1 };') and compatible with C++17.
>
> Isn't simplification of initialization rules a good enough argument?
>
> Aah, I forgot to write, I propose to unify direct-init and copy-init as
> well:
> T a = b;
> T a(b);
>
> In C++17 these will do exactly the same thing (minus explicit constructor).
>

Yeah, but "minus explicit constructor" is kind of significant. What you're
proposing is effectively to get rid of the explicit keyword.

The argument you have to make is that explicit adds no value. I, for one,
like that neither

vector<string> names() { return 3; }

nor

void timeout(std::chrono::seconds)
timeout(42);

compile today.

Barry

>



STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups