While you example can be re-written in a similar fashion with no major issues, it would have been a very useful tool to solve the problem with recursive template instantiation to embed declarations.

Compare those two and count template instances:

-------------------------------------------

mixin template head(T)
{
    mixin(generateCode!T);
}

mixin template list(T...)
    if (T.length >= 1)
{
    mixin head!(T[0]);
    static if (T.length > 1)
        mixin list!(T1..$]);
}

struct Test
{
    mixin list!(int, string, double);
}

-------------------------------------------

struct Test
{
    foreach (T; TypeTuple!(int, string, double))
    {
        mixin(generateCode!T));
    }
}

-------------------------------------------

I remember Andrei reacting quite positively to this proposal when talking on #d channel.

Reply via email to