www.digitalmars.com         C & C++   DMDScript  

D - problem with templates?

I am starting to like D templates but i have more problems!
I have a class set:

class set(A)
{
     this(){}
     bool insert(A a)
     {
          version(test){printf("About to insert %d",a);}
          if(!(a in skup))
          {
               skup[a]=1;
               version(test){printf("inserting\n");}
          }
          else
          {
               version(test){printf("exists\n");}
          }
          return true;
     }
     template Print(A)
     {
          int PrintSetSize(set!(A) a)
          {
               printf("\size iz %d",a.size());
          }
     }
     A[] Values(){return skup.keys;}
     int size(){return skup.length;}
     int[A] skup;
}
alias set!(int) IntegerSet;

And when i want to use it:

 IntegerSet integers = new IntegerSet();
 IntegerSet integers2 = new IntegerSet();
 integers.insert(5);
 integers.insert(3);
 integers.insert(5);
 assert(integeri.size==2);
 integers2.insert(5);
 integers2.insert(3);

//all this works but when i add the following line the compiler crashes:
integers.Print!(int).PrintSetSize(integers2);

also crashes with
IntegerSet.Print!(int).PrintSetSize(integers2);

So maybe i am doing something wrong??
The question is how to declare a member template function and how to use it?
How to pass to a member function an object of its own template type!

I would also like to be able to use the set class this way:
if(integrs2 == integers){...}
How can i do this?

I know i cant declare operators(opEquals?) outside the class and if i want
to declare it
inside the class it has to be non-static (to be able to use acces first
operand using this)
and D template member function can only be static??

I hope there is a way around this problem?
I think that operators should be allowed to be outside the class
and that the template member function should be allowed to be non-static!
Jan 26 2004