Question about template argument matching with alias this

Johannes Loher johannes.loher at fg4f.de
Sun Jul 29 16:43:08 UTC 2018


I have a question about template argument matching in combination 
with implicit conversion and alias this. Consider the following 
code:


interface SomeInterface
{
}

class SomeClass : SomeInterface
{
}

struct SomeStruct
{
     SomeClass someClass;
     alias someClass this;
}

template isSuperType(T, S : T)
{
     enum isSuperType = is(SomeStruct : SomeInterface);
}

void main()
{
     static assert(is(SomeStruct : SomeInterface));
     static assert(isSuperType!(SomeInterface, SomeStruct)); // 
why does the template not match?
}


The question is, why does the template declaration not match? 
Thanks for your help!


More information about the Digitalmars-d-learn mailing list