Re: Some strange parameter deduction problems in opOpAssign and opBinary

2012-09-02 Thread Ivan Agafonov
On Sunday, 2 September 2012 at 07:44:12 UTC, Philippe Sigaud wrote: Problem solved: alias Vec!(T, size) V; // This works fine ref V opOpAssign(string op)(V rhs) { mixin("array[] "~op~"= rhs.array[];"); return this; } Inside a template, you can refer to the current (lo

Re: Some strange parameter deduction problems in opOpAssign and opBinary

2012-09-02 Thread Ali Çehreli
On 09/01/2012 10:08 PM, Ivan Agafonov wrote: > On Sunday, 2 September 2012 at 04:10:39 UTC, Ivan Agafonov wrote: >> There are 3 separated versions of opOpAssign >> first version must be the same as the second for Vec!(sometype, 4) >> why it doesn't work? >> >> Simplified code: >> >> struct Vec(T,

Re: Some strange parameter deduction problems in opOpAssign and opBinary

2012-09-02 Thread Philippe Sigaud
> Problem solved: > > alias Vec!(T, size) V; > > // This works fine > ref V opOpAssign(string op)(V rhs) > > { > mixin("array[] "~op~"= rhs.array[];"); > return this; > } Inside a template, you can refer to the current (local) instantiation by its name only. Try using 'Vec'

Re: Some strange parameter deduction problems in opOpAssign and opBinary

2012-09-01 Thread Ivan Agafonov
On Sunday, 2 September 2012 at 04:10:39 UTC, Ivan Agafonov wrote: There are 3 separated versions of opOpAssign first version must be the same as the second for Vec!(sometype, 4) why it doesn't work? Simplified code: struct Vec(T, uint size) { this(T rhs) { array[] = rhs; }

Re: Some strange parameter deduction problems in opOpAssign and opBinary

2012-09-01 Thread Ivan Agafonov
Hmm, strange... z.opOpAssign!"+"(z); works with both first and second versions

Some strange parameter deduction problems in opOpAssign and opBinary

2012-09-01 Thread Ivan Agafonov
There are 3 separated versions of opOpAssign first version must be the same as the second for Vec!(sometype, 4) why it doesn't work? Simplified code: struct Vec(T, uint size) { this(T rhs) { array[] = rhs; } // It doesn't work but compiles ref Vec!(T, size) opOpA