> If I'm not mistaken isn't the "code" I'm trying to generate still in a
> string?
>

Well, yes, but not when you mix it in. It's a string mixin in this case,
not a template mixin.


>
> (you've unfortunately left out the most important part at `//build your
> code here`)
>


Because it's just simple string operations using the entire
language/Phobos/whatever to get the code you want. And then, you mix it in.

Anonymous gave you http://dpaste.dzfl.pl/5d4cb742

With a string mixin, this gives:

http://dpaste.dzfl.pl/8fc32179

string genStruct(string stringname)
{
    return
    "struct " ~ stringname ~ "
    {
        //....
    }";
}

mixin(genStruct("s1"));
mixin(genStruct("s2"));

static assert(is(s1));
static assert(is(s2));

void main() {}

Reply via email to