allMembers
Manu
turkeyman at gmail.com
Fri May 4 06:28:33 PDT 2012
So I do a lot of module scanning via allMembers, and I'm consistently
running into an awkward problem:
module test.blah;
static this()
{
foreach(m; __traits(allMembers, test.module))
{
// 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...
// I need to know if m is an interface, class or struct
static if( is( mixin(m) == [interface/class/struct] ) ) // how can I
do this? I can't use mixin() here.
// 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:
static if( is( typeof( mixin( m ) ) ) ) // this works!
{
// here, I know that m is an instance of something, which means I can
alias it's typeof()
alias typeof( mixin( m ) ) Type;
// ... and life is good
static if( is( Type == function ) )
{
...
}
}
// that construct doesn't work for definitions, like
interface/class/struct
}
}
What can I do?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120504/111ad903/attachment-0001.html>
More information about the Digitalmars-d
mailing list