Referring to alias parameters in a mixin template

aldanor via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 16 17:14:35 PST 2014


A partial solution would be something like this:

     mixin template makeProperty(T, string name, alias func) {
         enum p = makeUnnamedProperty!(T, func);
         mixin("enum %s = p;".format(name)); // or alias
     }

however now the parent namespace is polluted with "p", is there 
any way to hide it away and/or avoid it?

I may be wrong, but I guess the whole thing boils down to a 
question whether it's possible to have a mixin template with 
signature 'bind(string name, alias symbol)' which generates 'enum 
foo = bar;' when called as 'mixin bind!("foo", bar)'?


More information about the Digitalmars-d-learn mailing list