Re: Combining variadic functions with class templates

2010-09-30 Thread bearophile
Sebastian Schuberth: > I'm all new to D (coming from C++), and currently playing around with > the language. I'm using DMD 2.049 and was expecting this to compile: > > struct Vector(alias N,T) > { > Vector(T[N] v ...) { > data=v; > } > > T data[N]; > }; > > alias Vector

Re: Combining variadic functions with class templates

2010-09-30 Thread Philippe Sigaud
>> Thanks, that works, but that syntax seems a little verbose to me. Is the >> first syntax generally not supported in D? >> > > It is not. You can use auto v = Vec3f(1,1,1); If you use a creation function, types and length are deduced automatically, there is no need to indicate them to the compil

Re: Combining variadic functions with class templates

2010-09-30 Thread Pelle
On 09/30/2010 08:25 PM, Sebastian Schuberth wrote: On 30.09.2010 20:20, wrzosk wrote: void main() { Vec3f v(1,1,1); } I still get Building Release\ConsoleApp1.exe... main.d(14): found 'v' when expecting ';' following statement Building Release\ConsoleApp1.exe failed! Change Vec3f v(1,1,1);

Re: Combining variadic functions with class templates

2010-09-30 Thread Sebastian Schuberth
On 30.09.2010 20:20, wrzosk wrote: void main() { Vec3f v(1,1,1); } I still get Building Release\ConsoleApp1.exe... main.d(14): found 'v' when expecting ';' following statement Building Release\ConsoleApp1.exe failed! Change Vec3f v(1,1,1); into Vec3f v = Vec3f(1,1,1); Thanks, that works, b

Re: Combining variadic functions with class templates

2010-09-30 Thread wrzosk
W dniu 2010-10-01 03:13, Sebastian Schuberth pisze: On 30.09.2010 19:58, Simen kjaeraas wrote: This is not a constructor, but a malformed function. In D, constructors bear the name 'this'[1]. Doh, thanks, I should have already known that ... changing "Vector" to "this" makes it better, but wi

Re: Combining variadic functions with class templates

2010-09-30 Thread Sebastian Schuberth
On 30.09.2010 19:58, Simen kjaeraas wrote: This is not a constructor, but a malformed function. In D, constructors bear the name 'this'[1]. Doh, thanks, I should have already known that ... changing "Vector" to "this" makes it better, but with struct Vector(alias N,T) { this(T[N] v ...)

Re: Combining variadic functions with class templates

2010-09-30 Thread Simen kjaeraas
Sebastian Schuberth wrote: Hi, I'm all new to D (coming from C++), and currently playing around with the language. I'm using DMD 2.049 and was expecting this to compile: struct Vector(alias N,T) { Vector(T[N] v ...) { This is not a constructor, but a malformed function. In D, constr

Combining variadic functions with class templates

2010-09-30 Thread Sebastian Schuberth
Hi, I'm all new to D (coming from C++), and currently playing around with the language. I'm using DMD 2.049 and was expecting this to compile: struct Vector(alias N,T) { Vector(T[N] v ...) { data=v; } T data[N]; }; alias Vector!(3,float) Vec3f; void main() { Vec3f v(