Nested Structs (Solution)

Mafi mafi at example.org
Thu Dec 13 12:56:04 PST 2012


On Wednesday, 12 December 2012 at 22:58:47 UTC, Max Samukha wrote:
> On Wednesday, 12 December 2012 at 22:19:54 UTC, js.mdnq wrote:
>> Also, I initially tried to do
>>
>> 	B!(A.b1.offsetof) b1;
>>
>> a'la
>>
>> http://forum.dlang.org/thread/mailman.2627.1355335532.5162.digitalmars-d@puremagic.com
>>
>> but dmd 2.060 crashes, which is why I moved on to using a 
>> static if.
>
> That's 'outer', yet another half-done D feature. It should be 
> implemented for nested structs.

It's not half-done. Structs are supposed to be POD. They should
contain exactly the members that you list; no more hidden stuff.
See TDPL 7.1.8 (p.262): "Unlike classes netsted within classes,
nested structs and nested classes within structs dont contain any
hidden member outer - there's no special code generated."
I am not sure about classes within structs but nested structs
should behave like they do IMHO.

Mafi


More information about the Digitalmars-d mailing list