Merge pull request #21 from s-ludwig/issue_18_opbinary_ambiguity

Don't define ambiguous opBinary/opBinaryRight overloads
This commit is contained in:
Sönke Ludwig 2019-02-22 03:07:41 +01:00 committed by GitHub
commit b78003531e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -208,7 +208,9 @@ struct TaggedAlgebraic(U) if (is(U == union) || is(U == struct))
/// Enables the use of binary operators with the stored value.
auto opBinary(string op, T, this TA)(auto ref T other) if (hasOp!(TA, OpKind.binary, op, T)) { return implementOp!(OpKind.binary, op)(this, other); }
/// Enables the use of binary operators with the stored value.
auto opBinaryRight(string op, T, this TA)(auto ref T other) if (hasOp!(TA, OpKind.binaryRight, op, T)) { return implementOp!(OpKind.binaryRight, op)(this, other); }
auto opBinaryRight(string op, T, this TA)(auto ref T other) if (hasOp!(TA, OpKind.binaryRight, op, T) && !isInstanceOf!(TaggedAlgebraic, T)) { return implementOp!(OpKind.binaryRight, op)(this, other); }
/// ditto
auto opBinaryRight(string op, T, this TA)(auto ref T other) if (hasOp!(TA, OpKind.binaryRight, op, T) && isInstanceOf!(TaggedAlgebraic, T) && !hasOp!(T, OpKind.opBinary, op, TA)) { return implementOp!(OpKind.binaryRight, op)(this, other); }
/// Enables operator assignments on the stored value.
auto opOpAssign(string op, T, this TA)(auto ref T other) if (hasOp!(TA, OpKind.binary, op~"=", T)) { return implementOp!(OpKind.binary, op~"=")(this, other); }
/// Enables indexing operations on the stored value.