On Sunday, 21 October 2012 at 20:54:15 UTC, ref2401 wrote:
On Sunday, 21 October 2012 at 20:42:08 UTC, cal wrote:
On Sunday, 21 October 2012 at 20:34:51 UTC, ref2401 wrote:
what should i do to make my binary operation commutative?

in the following case

auto v5 = v1 + v2;

there will be compile time error:
overloads pure @safe MyClass(MyClass rhs) and pure @safe MyClass(MyClass lhs) both match argument list for opBinary

Oh right, sorry. Well if all you want to do is catch the null on either side of the '+', you could use this overload of opBinaryRight:

MyClass opBinaryRight(string op: "+", T)(T rhs) if (!is(T == MyClass))
{                       
  return null;  
}

I'm not sure if this is what you are trying to do though...

Reply via email to