Re: Passing a generic struct as parameter

2011-07-01 Thread Zardoz
Ok, I fixed it. I just need to put (K) type parameter to the other opIndexAssign D not allow overload operators/methods with different type parameters. They must share same type parameters : void opIndexAssign(K)(K c, size_t row, size_t cl) {... } void opIndexAssign(K) (K v, size_t j) { ... }

Re: Passing a generic struct as parameter

2011-07-01 Thread Zardoz
Finally I try this small test code : struct A(T, int U) { T x; static enum foo = U; Tout opCast( Tout ) () if (isA!Tout) { Tout nt; nt.x = x; return nt; } string toString() {

Re: Passing a generic struct as parameter

2011-07-01 Thread Simen Kjaeraas
On Fri, 01 Jul 2011 08:58:32 +0200, Zardoz wrote: Well, the problem is that I must do the cast always, see : // alias Matrix!(real,4) Mat4r; // alias Vector!(float, 3) Vec3f; // alias Vector!(real, 4) Vec4r; // In Mat4r, VCol it's aliased to Vector!(real, 4) auto tcol = Mat4r.IDENTITY; auto

Re: Passing a generic struct as parameter

2011-07-01 Thread Zardoz
Thanks. I imagined something similar, that "Vector" alone not is type. How I can templatize opIndexAssign function ? I tried this : void opIndexAssign(U)(U v, size_t j) { col[j] = v; } And I get a error : Error: template zmath.matrix.Matrix!(float,2).Matrix.opIndexAssign(U) conflicts with fun

Re: Passing a generic struct as parameter

2011-06-30 Thread Zardoz
Well, the problem is that I must do the cast always, see : // alias Matrix!(real,4) Mat4r; // alias Vector!(float, 3) Vec3f; // alias Vector!(real, 4) Vec4r; // In Mat4r, VCol it's aliased to Vector!(real, 4) auto tcol = Mat4r.IDENTITY; auto v = cast(tcol.VCol) Vec3f(1, 2 ,3 ); auto v2 = Vec4r

Re: Passing a generic struct as parameter

2011-06-30 Thread Simen Kjaeraas
On Fri, 01 Jul 2011 01:39:53 +0200, Zardoz wrote: I have a parametrized struct (Vector!(T, dim)) that takes two parameters (Type and a number). And made some Alias with defaults parameters. In other struct (Matrix!(T, dim)), that uses these struct to represent a matrix in column-major order. I

Re: Passing a generic struct as parameter

2011-06-30 Thread Jonathan M Davis
On 2011-06-30 16:39, Zardoz wrote: > I have a parametrized struct (Vector!(T, dim)) that takes two parameters > (Type and a number). And made some Alias with defaults parameters. > > In other struct (Matrix!(T, dim)), that uses these struct to represent a > matrix in column-major order. I have a i

Passing a generic struct as parameter

2011-06-30 Thread Zardoz
I have a parametrized struct (Vector!(T, dim)) that takes two parameters (Type and a number). And made some Alias with defaults parameters. In other struct (Matrix!(T, dim)), that uses these struct to represent a matrix in column-major order. I have a internall alias for Vector using internally