From: Daniel Karbach Date: Fri, 10 Aug 2012 11:05:24 +0000 (+0200) Subject: added -= operators for Point/Vector X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=cc77c50e59e9e3e4d5394d5fcf6905372fb7fe86;p=l2e.git added -= operators for Point/Vector --- diff --git a/src/geometry/operators.h b/src/geometry/operators.h index 2dfa54e..295daa1 100644 --- a/src/geometry/operators.h +++ b/src/geometry/operators.h @@ -26,13 +26,11 @@ inline Point operator +(const Point &lhs, const Vector &rhs) { template inline Vector &operator +=(Vector &lhs, const Vector &rhs) { - lhs = lhs + rhs; - return lhs; + return lhs = lhs + rhs; } template inline Point &operator +=(Point &lhs, const Vector &rhs) { - lhs = lhs + rhs; - return lhs; + return lhs = lhs + rhs; } template @@ -44,6 +42,15 @@ inline Point operator -(const Point &lhs, const Vector &rhs) { return Point(lhs.X() - rhs.X(), lhs.Y() - rhs.Y()); } +template +inline Vector &operator -=(Vector &lhs, const Vector &rhs) { + return lhs = lhs - rhs; +} +template +inline Point &operator -=(Point &lhs, const Vector &rhs) { + return lhs = lhs - rhs; +} + template inline Vector operator -(const Vector &v) { return Vector(-v.X(), -v.Y());