C++ Logo

std-proposals

Advanced search

Re: Fixing some initialization gotchas

From: Maciej Cencora <m.cencora_at_[hidden]>
Date: Fri, 23 Aug 2019 20:37:57 +0200
With having a couple of people respond to my ideas, you were the only that
seem to agree at least with some of it IIUC.
That is not very encouraging.

How many committee members are subscribed to this list?
Should I wait for +1 from at least one of them before writing proper
proposal (to get non zero chance of getting anything of it accepted)?
Currently I have -1 from Villie, and -1 from everyone else besides you, so
I feel like creating a proper proposal would be waste of time.


pt., 23 sie 2019 o 18:40 Matthew Woehlke <mwoehlke.floss_at_[hidden]>
napisaƂ(a):

> On 23/08/2019 11.35, Ville Voutilainen via Std-Proposals wrote:
> > On Fri, 23 Aug 2019 at 18:21, Maciej Cencora wrote:
> >> I cannot pass multiple elements in that form now, but it was possible
> before in C++11.
> >>
> >> It is a simplification, because it avoids ambiguities, surprises, and
> removes corner cases.
> >> Currently this one compiles:
> >> auto x1 = { 1 };
> >> auto x2 = { 1, 1 };
> >> auto x3{ 1 };
> >> auto x4{ 1, 1 };
> >>
> >> Currently only x1 and x2 has same type, x4 does not compile, x1 and x2
> compiles only if you include initializer_list header.
> >> And x1 type is different then x3.
> >> This is complete bonkers!
> >
> > Indeed it is. But in order to get x3, some parties insisted on keeping
> > x1/x2 working as they were, so that's the compromise we have.
>
> Who actually *wanted* x3, and why?
>
> >> With my proposal the only allow auto declaration would be in following
> form:
> >> auto x = y;
> >> which is unambiguous, has no corner cases, and works just as right now.
> >
> > Yeah, and then T a{x}; works but auto a{x} doesn't, so yeah, you do
> > have corner cases.
>
> I could live with that. IMHO, `auto a{x}` doesn't make sense; there is
> no "obvious" rule how to determine what the type of `a` should be,
> unlike just about every other instance where `auto` is used. Consider
> that `{x}`, by itself, is a nonsense expression, If anything, I *could*
> see it as an initializer list, but making it equivalent to `x` doesn't
> make sense IMO.
>
> --
> Matthew
>

Received on 2019-08-23 13:40:12