C++ Logo

std-discussion

Advanced search

Re: Aggregate initialization with reuse?

From: Timur Doumler <cpp_at_[hidden]>
Date: Sun, 2 Jun 2019 17:28:06 +0200
Yes, sorry, there are no designated initialisers.

I was distracted by the braces and the dot and went into a completely wrong direction.

This happens if you're writing emails while being too tired! Sorry for the noise :)

Cheers,
Timur

> On 2 Jun 2019, at 17:09, Ville Voutilainen via Std-Discussion <std-discussion_at_[hidden]> wrote:
>
> On Sun, 2 Jun 2019 at 17:34, Language Lawyer via Std-Discussion
> <std-discussion_at_[hidden]> wrote:
>>
>> https://stackoverflow.com/a/32945791/9585016
>
> In other words,
>
> 1) a is in scope per http://eel.is/c++draft/basic.scope.pdecl#1
> 2) a.x has been completely initialized per
> http://eel.is/c++draft/dcl.init.aggr#6
>
> The initialization is well-formed, legal, and does what you expect.
> The earlier statements about designated initializers
> do not apply, but if we choose to modify the example to use designated
> initializers, it still works:
>
> struct {
> int x;
> int y;
> } a{.x = 42, .y = a.x};
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> http://lists.isocpp.org/mailman/listinfo.cgi/std-discussion

Received on 2019-06-02 10:33:38