diff --git a/std/bigint.d b/std/bigint.d index e4364f48c..a11d440f1 100644 --- a/std/bigint.d +++ b/std/bigint.d @@ -277,10 +277,11 @@ public: else if ((y > 0) == (op=="<<")) { // Sign never changes during left shift - data = data.opShl(u); - } else + data = data.opBinary!(op)(u); + } + else { - data = data.opShr(u); + data = data.opBinary!(op)(u); if (data.isZero()) sign = false; } diff --git a/std/bitmanip.d b/std/bitmanip.d index 95803486b..6bf59f2a7 100644 --- a/std/bitmanip.d +++ b/std/bitmanip.d @@ -2075,8 +2075,8 @@ public: * shared between BitArray objects. i.e. D dynamic array * concatenation semantics are not followed) */ - - BitArray opCatAssign(bool b) pure nothrow + BitArray opOpAssign(string op)(bool b) pure nothrow + if (op == "~") { length = _len + 1; this[_len - 1] = b; @@ -2105,8 +2105,8 @@ public: /*************************************** * ditto */ - - BitArray opCatAssign(BitArray b) pure nothrow + BitArray opOpAssign(string op)(BitArray b) pure nothrow + if (op == "~") { auto istart = _len; length = _len + b.length; @@ -2139,7 +2139,8 @@ public: /*************************************** * Support for binary operator ~ for `BitArray`. */ - BitArray opCat(bool b) const pure nothrow + BitArray opBinary(string op)(bool b) const pure nothrow + if (op == "~") { BitArray r; @@ -2150,7 +2151,8 @@ public: } /** ditto */ - BitArray opCat_r(bool b) const pure nothrow + BitArray opBinaryRight(string op)(bool b) const pure nothrow + if (op == "~") { BitArray r; @@ -2162,7 +2164,8 @@ public: } /** ditto */ - BitArray opCat(BitArray b) const pure nothrow + BitArray opBinary(string op)(BitArray b) const pure nothrow + if (op == "~") { BitArray r; diff --git a/std/internal/math/biguintcore.d b/std/internal/math/biguintcore.d index 9d83c17c5..dd4509213 100644 --- a/std/internal/math/biguintcore.d +++ b/std/internal/math/biguintcore.d @@ -599,7 +599,8 @@ public: // All of these member functions create a new BigUint. // return x >> y - BigUint opShr(Tulong)(Tulong y) pure nothrow const if (is (Tulong == ulong)) + BigUint opBinary(string op, Tulong)(Tulong y) pure nothrow const + if (op == ">>" && is (Tulong == ulong)) { assert(y>0); uint bits = cast(uint) y & BIGDIGITSHIFTMASK; @@ -622,7 +623,8 @@ public: } // return x << y - BigUint opShl(Tulong)(Tulong y) pure nothrow const if (is (Tulong == ulong)) + BigUint opBinary(string op, Tulong)(Tulong y) pure nothrow const + if (op == "<<" && is (Tulong == ulong)) { assert(y>0); if (isZero()) return this; diff --git a/std/variant.d b/std/variant.d index c938dc49b..315233f5f 100644 --- a/std/variant.d +++ b/std/variant.d @@ -1069,14 +1069,16 @@ public: is(typeof(opLogic!(T, op)(lhs)))) { return opLogic!(T, op)(lhs); } ///ditto - VariantN opCat(T)(T rhs) + VariantN opBinary(string op, T)(T rhs) + if (op == "~") { auto temp = this; temp ~= rhs; return temp; } // ///ditto - // VariantN opCat_r(T)(T rhs) + // VariantN opBinaryRight(string op, T)(T rhs) + // if (op == "~") // { // VariantN temp = rhs; // temp ~= this; diff --git a/std/xml.d b/std/xml.d index 743cd8e5e..f90338dfc 100644 --- a/std/xml.d +++ b/std/xml.d @@ -693,7 +693,7 @@ class Element : Item this(string name, string interior=null) @safe pure { this(new Tag(name)); - if (interior.length != 0) opCatAssign(new Text(interior)); + if (interior.length != 0) opOpAssign!("~")(new Text(interior)); } /** @@ -722,7 +722,8 @@ class Element : Item * element ~= new Text("hello"); * -------------- */ - void opCatAssign(Text item) @safe pure + void opOpAssign(string op)(Text item) @safe pure + if (op == "~") { texts ~= item; appendItem(item); @@ -740,7 +741,8 @@ class Element : Item * element ~= new CData("hello"); * -------------- */ - void opCatAssign(CData item) @safe pure + void opOpAssign(string op)(CData item) @safe pure + if (op == "~") { cdatas ~= item; appendItem(item); @@ -758,7 +760,8 @@ class Element : Item * element ~= new Comment("hello"); * -------------- */ - void opCatAssign(Comment item) @safe pure + void opOpAssign(string op)(Comment item) @safe pure + if (op == "~") { comments ~= item; appendItem(item); @@ -776,7 +779,8 @@ class Element : Item * element ~= new ProcessingInstruction("hello"); * -------------- */ - void opCatAssign(ProcessingInstruction item) @safe pure + void opOpAssign(string op)(ProcessingInstruction item) @safe pure + if (op == "~") { pis ~= item; appendItem(item); @@ -796,7 +800,8 @@ class Element : Item * // appends element representing
* -------------- */ - void opCatAssign(Element item) @safe pure + void opOpAssign(string op)(Element item) @safe pure + if (op == "~") { elements ~= item; appendItem(item); @@ -811,16 +816,16 @@ class Element : Item private void parse(ElementParser xml) { - xml.onText = (string s) { opCatAssign(new Text(s)); }; - xml.onCData = (string s) { opCatAssign(new CData(s)); }; - xml.onComment = (string s) { opCatAssign(new Comment(s)); }; - xml.onPI = (string s) { opCatAssign(new ProcessingInstruction(s)); }; + xml.onText = (string s) { opOpAssign!("~")(new Text(s)); }; + xml.onCData = (string s) { opOpAssign!("~")(new CData(s)); }; + xml.onComment = (string s) { opOpAssign!("~")(new Comment(s)); }; + xml.onPI = (string s) { opOpAssign!("~")(new ProcessingInstruction(s)); }; xml.onStartTag[null] = (ElementParser xml) { auto e = new Element(xml.tag); e.parse(xml); - opCatAssign(e); + opOpAssign!("~")(e); }; xml.parse();