C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: Aggregate initialization with reuse?
From: Timur Doumler (cpp_at_[hidden])
Date: 2019-06-02 09:12:03


No. According to P0329, you can neither mix designated and regular initialisers, nor can you write designated initialisers in the wrong order compared to their order of declaration in the struct.

Cheers,
Timur

> On 2 Jun 2019, at 15:26, Bjorn Reese via Std-Discussion <std-discussion_at_[hidden]> wrote:
>
> Assuming I have an aggregate, is it legal to initialize later member
> variables with earlier member variables?
>
> For instance, is it legal to use a.x in the aggregate initialization
> below:
>
> struct {
> int x;
> int y;
> } a{42, a.x};
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> http://lists.isocpp.org/mailman/listinfo.cgi/std-discussion


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

Older Archives on Google Groups