]> git.localhorst.tv Git - l2e.git/commitdiff
added mixed-type operators to Vector template
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 30 Sep 2012 14:23:24 +0000 (16:23 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Sun, 30 Sep 2012 14:23:24 +0000 (16:23 +0200)
src/geometry/Vector.h

index bf647136ddfaa101ee8406b0f8fa36cdccf2a4b4..562648b6b0f5013286f936537c1675c22cd6f917 100644 (file)
@@ -37,21 +37,37 @@ template<class T>
 inline Vector<T> operator +(const Vector<T> &lhs, const Vector<T> &rhs) {
        return Vector<T>(lhs.X() + rhs.X(), lhs.Y() + rhs.Y());
 }
 inline Vector<T> operator +(const Vector<T> &lhs, const Vector<T> &rhs) {
        return Vector<T>(lhs.X() + rhs.X(), lhs.Y() + rhs.Y());
 }
+template<class T, class U>
+inline Vector<T> operator +(const Vector<T> &lhs, const Vector<U> &rhs) {
+       return Vector<T>(lhs.X() + rhs.X(), lhs.Y() + rhs.Y());
+}
 
 template<class T>
 inline Vector<T> &operator +=(Vector<T> &lhs, const Vector<T> &rhs) {
        return lhs = lhs + rhs;
 }
 
 template<class T>
 inline Vector<T> &operator +=(Vector<T> &lhs, const Vector<T> &rhs) {
        return lhs = lhs + rhs;
 }
+template<class T, class U>
+inline Vector<T> &operator +=(Vector<T> &lhs, const Vector<U> &rhs) {
+       return lhs = lhs + rhs;
+}
 
 template<class T>
 inline Vector<T> operator -(const Vector<T> &lhs, const Vector<T> &rhs) {
        return Vector<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
 }
 
 template<class T>
 inline Vector<T> operator -(const Vector<T> &lhs, const Vector<T> &rhs) {
        return Vector<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
 }
+template<class T, class U>
+inline Vector<T> operator -(const Vector<T> &lhs, const Vector<U> &rhs) {
+       return Vector<T>(lhs.X() - rhs.X(), lhs.Y() - rhs.Y());
+}
 
 template<class T>
 inline Vector<T> &operator -=(Vector<T> &lhs, const Vector<T> &rhs) {
        return lhs = lhs - rhs;
 }
 
 template<class T>
 inline Vector<T> &operator -=(Vector<T> &lhs, const Vector<T> &rhs) {
        return lhs = lhs - rhs;
 }
+template<class T, class U>
+inline Vector<T> &operator -=(Vector<T> &lhs, const Vector<U> &rhs) {
+       return lhs = lhs - rhs;
+}
 
 template<class T>
 inline Vector<T> operator -(const Vector<T> &v) {
 
 template<class T>
 inline Vector<T> operator -(const Vector<T> &v) {