On Friday, 26 October 2012 at 15:14:56 UTC, Dan wrote:
Still trying to understand this. I found that if I change the
following in Proxy it this example (r1 + r2) works fine. Plus
the unit tests that are there still work. But, honestly I don't
understand why...yet.
Thanks,
Dan
----- From typecons.Proxy -----
auto ref opBinary (string op, this X, B)(auto ref B b)
{ return mixin("a "~op~" b"); }
----- To -----
auto ref opBinary (string op, this X, B)(auto ref B b)
if(!is(X == B)) { return mixin("a "~op~" b"); }
-----
From http://dlang.org/operatoroverloading.html, it is an error
for both overloads of opBinary (opBinary and opBinaryRight) to
match. Since the signatures for the two overloads in std.typecons
are identical, this looks like a bug to me.
Your modified version works (far as I can see) because it
excludes one of the overloads from being matched, allowing the
other to be used (opBinaryRight).