On Monday, 22 August 2016 at 18:48:12 UTC, ag0aep6g wrote:
You can take this further with template constraints. Gives it a more uniform appearance at the price of some repetition:

----
class T()
{
    int x;
}

class T(A...) : T!(A[0..$-1])
    if (A.length > 0 && A[$-1] == "Animal")
{
    int y;
}

class T(A...) : T!(A[0..$-1])
    if (A.length > 0 && A[$-1] == "Dog")
{
    int z;
}

class T(A...) : T!(A[0..$-1])
    if (A.length > 0 && A[$-1] == "Pug")
{
    int s;
}
Yes. And even simpler, if to change the order of template parameters:

class T() {
    int x;
}

class T(string type : "Animal", A...) : T!A {
    int y;
}

class T(string type : "Dog", A...) : T!A {
    int z;
}

class T(string type : "Pug", A...) : T!A {
    int s;
}

Reply via email to