Can we just have struct inheritence already?
Walter Bright
newshound2 at digitalmars.com
Mon Jun 10 09:35:25 UTC 2019
On 6/9/2019 10:13 PM, Nicholas Wilson wrote:
> On Monday, 10 June 2019 at 04:03:38 UTC, Nicholas Wilson wrote:
>> There is a (proposal?) for a no unique address attribute to disappear the
>> address of structs the take up no room.
>
> Found it:
>
> https://en.cppreference.com/w/cpp/language/attributes/no_unique_address
>
> Looks like there are a bunch of weird edge cases with it though:
>
> struct Empty {};
>
> struct Z {
> char c;
> [[no_unique_address]] Empty e1, e2;
> };
>
> // e1 and e2 cannot share the same address because they have the
> // same type, even though they are marked with [[no_unique_address]].
> // However, either may share address with c.
> static_assert(sizeof(Z) >= 2);
>
I didn't know about that attribute. Thanks for digging it up. Sheesh.
More information about the Digitalmars-d
mailing list