Finding out if T is a specialization of another template

Sean Eskapp eatingstaples at gmail.com
Fri Feb 18 09:16:02 PST 2011


I was given this code, to check if Y is a specialization of Bar. How does it work?

class Bar(T)
{
}

void foo(Y)()
{
    static if (is(Y Z == Bar!Z))
    {
        // Here, Z is now an alias to whichever type Bar is
        // instantiated with.
    }
    else
    {
        // Z is invalid here.
    }
}


More information about the Digitalmars-d-learn mailing list