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
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,
> 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'
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; }
Hmm, strange...
z.opOpAssign!"+"(z); works with both first and second versions
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