On Tue, Apr 26, 2011 at 22:06, Benjamin Thaut <c...@benjamin-thaut.de> wrote: > The Problem with that version is, that the code that is generated looks like > > void main(string[] args){ > auto test = new Foo!(int,float,double,short,byte)(); > test.print(); > test.echo!double(double.init); > test.echo!short(short.init); > } > > If the types that are used, are no simple data types, but rather large > structs, they are copied on every function call. Thats exactly what I want > to avoid. The Type2Type template has a size of 0, thats why I'm using that > in the first place.
In that case, just use echo(U)() { ...}, like this: import std.stdio; class Foo(T,R...) : Foo!(R) { public void print(){ writefln(T.stringof); super.print(); } public void echo(U)() { writefln(U.stringof); } } class Foo(T){ public void print(){ writefln("end: " ~ T.stringof); } public void echo(U)() { writefln(U.stringof); } } void main(string[] args){ auto test = new Foo!(int,float,double,short,byte)(); test.print(); test.echo!double; test.echo!short; } What's your global goal with this construction? What are you trying to achieve?