I use this Typedef implementation instead:

/// one with non-default initializer
template Typedef(T, istring name, T initval)
{
static assert (name.length, "Can't create Typedef with an empty identifier");

            enum Typedef =
                ("struct " ~ name ~
                "{ " ~
T.stringof ~ " value = " ~ initval.stringof ~ ";" ~
                "alias value this;" ~
                " }");
}

/// basic overload
template Typedef(T, istring name)
{
static assert (name.length, "Can't create Typedef with an empty identifier");

            enum Typedef =
                ("struct " ~ name ~
                "{ " ~
                T.stringof ~ " value; " ~
                "alias value this;" ~
                " }");
}

unittest
{
    mixin(Typedef!(int, "MyInt1"));
    mixin(Typedef!(int, "MyInt2"));

    static assert (!is(MyInt1 : MyInt2));
}

Reply via email to