digitalmars.D.learn - Question on class templates
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
Jun 07 2013
On Friday, 7 June 2013 at 17:52:48 UTC, Eric wrote: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, Ericclass X(K) : Identity!(X, K) auto x = new X!(double)(6.0);
Jun 07 2013
On Friday, 7 June 2013 at 18:06:26 UTC, anonymous wrote:On Friday, 7 June 2013 at 17:52:48 UTC, Eric wrote:Oh... Duh... Thanks.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, Ericclass X(K) : Identity!(X, K) auto x = new X!(double)(6.0);
Jun 07 2013