Templates and stringof...

Era Scarecrow rtcvb32 at yahoo.com
Fri Aug 3 14:02:21 PDT 2012


  While working on bitfields code I've found a unique scenario 
that poses some annoyances when generating the code.


template XYZ(alias x) {
     enum XYZ = x.stringof ~ "=100;";
}

struct I { int i;}

I i_num;
int n;

mixin(XYZ!(i_num.i)); //cannot find variable i
mixin(XYZ!(n));

the mixins become:
i=100;
n=100;


  Now, how do I get the template's stringof to print out 'i_num.i' 
and not 'i'?


More information about the Digitalmars-d-learn mailing list