C++ Logo


Advanced search

Subject: Re: [std-proposals] Fixing some initialization gotchas
From: Maciej Cencora (m.cencora_at_[hidden])
Date: 2019-08-23 10:12:02

I never proposed to make following work:
void timeout(std::chrono::seconds)

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

As already stated, if LEWG does not agree on for changing the rules w.r.t.
allowing non-explicit constructors in 'return braced init-list;' that is
fine. That is not the motivation for this proposal.

Motivation is to unify/simplify rules w.r.t. variable/member
initialization *during
declaration* *only* (no changes w.r.t. conversions in scope of function
call parameters, maybe for return value - but this is optional).

pt., 23 sie 2019 o 16:33 Barry Revzin <barry.revzin_at_[hidden]> napisał(a):

> 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 std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups