Template tuple parameters of classes
ws
wisiong at gmail.com
Sun Aug 3 22:03:05 PDT 2008
tsalm Wrote:
> Another question in the same sense : is there a way to do this :
> ( the aim is to work with the type (T) of the instance of MyClass )
>
> /* --------------------------------------- */
> import tango.io.Stdout;
>
> class MyClass(T)
> {}
>
> template Print(U: MyClass!(T),T ...)
> {
> void Print()
> {
> static if (U.length >= 1)
> {
> Stdout(T[0].sizeof);
> Print!(U[1..$]);
> }
> }
> }
>
> void main()
> {
> auto mine1 = new MyClass!(int);
> auto mine2 = new MyClass!(double);
> auto mine3 = new MyClass!(float);
> Print!(mine1,mine2,mine3);
> }
> /* --------------------------------------- */
If you are looking for variadic template parameters that work together with constraint, i am not sure if it can be done at the moment. Maybe when concept is ready?
http://www.digitalmars.com/d/2.0/concepts.html
More information about the Digitalmars-d-learn
mailing list