<div>Greetings</div><div><br></div>I thought I would be able to use allMembers/getMembers traits to access the attributes of all the members of a class. But that fails me if some members of the class are private.<div><br></div>
<div>Consider the code pasted below -- I get en error:</div><div><br></div><div><div>B.d(5): Error: class A.Foo member bar is not accessible</div></div><div><br></div><div>And so it seems it is essential that tupleof works with getAttributes, since tupleof does not care for access protection.</div>
<div><br></div><div>I have filed a bug on Budzilla. <a href="http://d.puremagic.com/issues/show_bug.cgi?id=9178">http://d.puremagic.com/issues/show_bug.cgi?id=9178</a></div><div><br></div><div>Regards</div><div>- Puneet</div>
<div><br></div><div><div>module A;</div><div>enum Boo;</div><div>class Foo {</div><div> private @Boo int bar;</div><div>}</div><div><br></div></div><div><div>module B;</div><div>void main() {</div><div> import A;</div>
<div>
Foo foo = new Foo;</div><div> static if(__traits(getProtection, __traits(getMember, foo, "bar")) // <-- can not access foo.bar</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> == "public")</div>
<div> {</div><div> // Check for attribute Boo and proceed</div><div> }</div><div>}</div></div><div><br></div>