www.digitalmars.com         C & C++   DMDScript  

D - Always with the templates!

Sorry, I just like 'em.  Regardless of how awkward and broken in C++,
they rule.

template A(T) {
   void func(T *a) { }
}

class B {
   static void func(int *a) { }
}

template C(T, FuncType) {
   void doIt(T *a) { FuncType.func(a); }
}

int main(char[][] args) {
   int x;

   instance C(int, B) doer;                   // this works
   doer.doIt(&x);

   instance C(int, instance A(int)) doer2;    // this does not
   doer2.doIt();

   return x;
}

Why can't a template instance be treated as a type?
Aug 08 2003