Passing a module in a template parameter list to __traits(allMembers, module)
Ben Gertzfield
bgertzfield at gmail.com
Tue Feb 26 11:03:00 PST 2013
Hi folks,
In preparation for my upcoming talk at DConf 2013, I'm working on
a compile-time dependency injection prototype for D.
I'd like part of public interface for this system to take a
module at compile time, and return a list of the classes in that
module. Something like:
string GetMembers(T)() {
auto members = [__traits(allMembers, T)];
return join(result, ", ");
}
If I pass a module to __traits(allMembers, foo.bar) outside a
template parameter list, it works great, but as soon as I pass it
through a template parameter list, I get an odd error:
Error: template instance GetMembers!(std) GetMembers!(std) does
not match template declaration GetMembers(T)()
Here's the code I'm working on. Any thoughts on whether this is
possible, and if so, what I'm doing wrong?
http://pastebin.com/BgZ67h8P
Thanks,
Ben
More information about the Digitalmars-d
mailing list