Is this template constraint a bug?

Eric via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 12 08:33:24 PDT 2016


is(T : A!T) tells if T can automatically be converted to A!T.  The
last line below is doing just that, yet the template constraint 
does not work.

class A(T) if (is(T : A!T))
{
}

// if (is(T : A!T)) gives this error:
// Error: template instance x.A!(B) does not match
//        template declaration A(T) if (is(T : A!T))
//        while looking for match for A!(B)

class B : A!(B)
{
}

void main(string[] args)
{
     B b = new B();
     A!B a = b; // compiles fine
}

-Eric


More information about the Digitalmars-d-learn mailing list