Template tuple parameters of classes

Tsalm tsalm at free.fr
Thu Jul 31 12:52:37 PDT 2008


On Wed, 30 Jul 2008 21:33:05 -0400, ws wrote:

> TSalm Wrote:
>> I've got a class MyClass :
>>   class MyClass(T) {}
>> 
>> And I need them in Template Tuple Parameter. Something like this :
>>   void myFunction
>>           ( U:MyClass!(T),T , U2:MyClass!(T2),T2... ) ( U myClass , U2
>>           myClass2...)
>>   	  {  /* ...some code... */ }
>> 
>> 
>> call by :
>>   MyClass!(int) mine1;
>>   MyClass!(double) mine2;
>>   MyClass!(char) mine3;
>>   myFunction( mine1 , mine2 , mine3 );
>> 
>> but.of course, 'myFunction' is incorrect... How to declare it ?
>> 
> 
> Perhaps this post by Jarrett is of help:
> http://lists.puremagic.com/pipermail/digitalmars-d/2007-
October/026373.html

It is very interresting. Thanks.


I'm trying this :
/* -------------------- */
class MyClass(T)
{
 T getTypeMin() {return T.min;}
}

template Print(U ...)
{
  void Print()
  {
    Stdout(U[0].getTypeMin()).newline;
  }
}

void main()
{
  MyClass!(int) mine1;
  MyClass!(double) mine2;
  MyClass!(float) mine3;
  
  Print!(mine1,mine2,mine3);
}
/* -------------------- */

But the execution send me an Access Violation !?


More information about the Digitalmars-d-learn mailing list