Template to create a type and instantiate it

cy via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Feb 4 23:41:05 PST 2016


I'm guessing I have to use a "mixin" mixin for this, but... 
there's no way to do something like this is there?

template TFoo(T) {

struct T {
   int a;
   int b;
}

T obj;
}

TFoo!Derp;
Derp bar;

Neither templates, nor mixin templates seem capable of this. Easy 
enough to use mixin, with tokenized string literal format, I 
think. I just hesitate to make opaque string evaluation a thing 
if some more meaningful method exists.


More information about the Digitalmars-d-learn mailing list