Why getting private member fails using getMember trait in a template?

Marc Schütz via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Sep 30 01:51:59 PDT 2015


On Wednesday, 30 September 2015 at 07:57:59 UTC, Atila Neves 
wrote:
> On Tuesday, 29 September 2015 at 09:40:41 UTC, Alexandru 
> Ermicioi wrote:
>> On Saturday, 26 September 2015 at 10:10:39 UTC, Alexandru 
>> Ermicioi wrote:
>>> Suppose we have, two modules:
>>>
>>> module testOne;
>>>
>>> [...]
>>
>> So, is this behavior correct?
>> If yes, then why?
>
> Yes, because private members aren't accessible from another 
> module. If they need to be accessed, then they need to be 
> public.
>
> Atila

As a workaround, you should be able to determine the index of the 
member (i.e. the how-many-th member it is in your struct/class), 
and then use .tupleof to access it, which circumvents access 
checks.


More information about the Digitalmars-d-learn mailing list