Nested struct member has no access to the enclosing class data

RivenTheMage riven-mage at id.ru
Tue Aug 7 00:01:50 PDT 2012


On Monday, 6 August 2012 at 23:42:45 UTC, Era Scarecrow wrote:
> On Monday, 6 August 2012 at 22:28:40 UTC, RivenTheMage wrote:
>> On Monday, 6 August 2012 at 21:51:24 UTC, Andrej Mitrovic 
>> wrote:
>>
>>> There is no "outer". A nested struct has the same access as a 
>>> nested static class, meaning no access to any outer members 
>>> unless they're static.
>>
>> Is there somewhere I can read the rationale behind that 
>> decision?
>
>  Let's assume you create the struct, then pass it back out as a 
> returned item (quite common); Later the class gets destructed. 
> What happens with/to the struct? Since static functions/members 
> are always accessible at compile time nothing changes. Perhaps
> your struct should probably be a class instead?

In my program the class is a special kind of container, and the
struct is a С#-style iterator.

Common approach (std.container) is to copy all necessary data
inside the range through the constructor, it's good if traversing
is simple, but in my case it's inconvenient.

Anyway, it seems I have little choice :)

Thanks for help!


More information about the Digitalmars-d-learn mailing list