On Thursday, 25 October 2012 at 16:39:57 UTC, Dan wrote:
From bug tracker I see that Proxy has a few issues, so this has
likely been seen. But what would cause this error?
tmp/c.d(16): Error: overloads pure nothrow @safe double(auto
ref CcRate b) and pure nothrow @safe double(auto ref CcRate b)
both match argument list for opBinary
The error refers to two methods with the same signature. In
typecons there are only two "Binary" methods, opBinary and
opBinaryRight, both in Proxy, so where is the
duplication/conflict coming from?
Thanks
Dan
---------------
import std.stdio;
import std.typecons;
import std.algorithm;
struct CcRate {
private double rate = 0;
mixin Proxy!rate;
this(double rate) {
this.rate = rate;
}
}
unittest {
CcRate r1 = 0.033, r2 = 0.002;
writeln(r1+r2); // compile error
}
---------------
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"); }
-----