template subclass as template parameter

Ivo Jimenez ivo.jimenez at gmail.com
Wed Aug 11 19:02:04 PDT 2010


Hi,

I'm new to D. I have the following:

   class A(T) { ... }
   class B(T) : A!(T) { ... }

   class C(T, U : A!(T)) { ... }

And I'm trying to do this

   void main()
   {
       C!(double, B!(double)) var;
   }

but dmd complains:
   Error: template instance C!(double,B) does not match template declaration
C(T,U : A!(T))

If I change the line of main() by

   void main()
   {
       C!(double, A!(double)) var;
   }

it works OK. Does the fact that B(T) is a child of A(T) imply that I can use
B(T) as a template parameter wherever A(T) is expected?

Could you please point to where I'm doing things wrong. I'd really
appreciate your feedback.

Thanks,
Ivo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100811/6b1808fd/attachment.html>


More information about the Digitalmars-d-learn mailing list