<br><br><div class="gmail_quote">On Sun, Jan 6, 2013 at 7:46 PM, d coder <span dir="ltr"><<a href="mailto:dlang.coder@gmail.com" target="_blank">dlang.coder@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div>You can use a string mixin:</div><div><br></div>
<div>class Foo</div>

<div>{</div><div>    int a;</div>
<div>    @(3) private int b;</div><div>}</div><div><br></div><div>void main()</div><div>{</div><div>    writeln(mixin("__traits(getAttributes, " ~ Foo.tupleof[1].stringof ~ ")")); // -> 3</div><div>



}</div><div><br></div><div> </div></div></blockquote><div><br></div></div><div>Hmm....</div><div><br></div><div>This works only when main is in the same file (and therefor module) as Foo.</div><div><br></div></div></blockquote>
<div><br></div><div>Yes, but the OP question was to get the attributes in a generic way. The interesting part is the mixin, the rest is just scaffolding to print a result.</div><div>If Jacob adopts this solution, he can insert these mixins where he needs them.</div>
<div><br></div><div><br></div></div>