Question on class templates

Eric eric at makechip.com
Fri Jun 7 10:52:46 PDT 2013


interface Identity(V, K)
{
}

class X(V, K) : Identity!(V, K)
{
     private K k;

     public this(K k) { this.k = k; }
}

void main()
{
     auto x = new X!(X, double)(6.0);
}

Hi -

I have the code above, but the line in main() gives the following 
compile error:
Error: template instance X!(X, double) does not match template 
declaration X(V, K)

If I change the template parameter X to something else, like 
string, it compiles fine.  But I want the Identity interface to 
know the type of the implementing class.  Is that possible?

Thanks,

Eric





More information about the Digitalmars-d-learn mailing list