C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Fixing Inheritance of Constructors from Aggregate bases

From: Barry Revzin <barry.revzin_at_[hidden]>
Date: Sun, 7 Apr 2024 11:33:09 -0500
On Sun, Apr 7, 2024, 11:26 AM Bjorn Reese via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Should the following work?
>
> template <typename T> struct A { T a; };
> template <typename T> struct B : A<T> { T a; };
> B<int> b{ .a = 1, .a = 2 };
>

If we're talking about my paper, then no it shouldn't work. But
B<int>{.a=1} should and would initialize the A<int>::a subobject to 0 and
the direct B<int>::a to 1 (in the wording there, the A<int>::a subobject
isn't a designatable member because b.a wouldn't name it).

Barry

>

Received on 2024-04-07 16:33:23