So I do a lot of module scanning via allMembers, and I'm consistently running into an awkward problem:<div><br></div><div>module test.blah;</div><div><br></div><div>static this()</div><div>{</div><div> foreach(m; __traits(allMembers, test.module))</div>
<div> {</div><div> // m is a string, the only way I know to address the thing m references is: mixin(m), and this can't be involved in virtually any complex expressions...</div><div><br></div><div> // I need to know if m is an interface, class or struct</div>
<div> static if( is( mixin(m) == [interface/class/struct] ) ) // how can I do this? I can't use mixin() here.</div><div><br></div><div><br></div><div> // I have a scenario where I need to know if m is a function, and I made it work using an ugly trick like this:</div>
<div><div> static if( is( typeof( mixin( m ) ) ) ) // this works!</div><div> {</div><div> // here, I know that m is an instance of something, which means I can alias it's typeof()</div><div> alias typeof( mixin( m ) ) Type;</div>
<div><br></div><div> // ... and life is good</div><div> static if( is( Type == function ) )</div><div> {</div></div><div> ...</div><div> }</div><div> }</div><div><br></div><div> // that construct doesn't work for definitions, like interface/class/struct</div>
<div><br></div><div> }</div><div>}</div><div><br></div><div>What can I do?</div>