]> git.localhorst.tv Git - l2e.git/blobdiff - src/geometry/Vector.h
added comparison operators to vector template
[l2e.git] / src / geometry / Vector.h
index bf647136ddfaa101ee8406b0f8fa36cdccf2a4b4..7c698ff4af0a11d9b707cd0b51503142e016f475 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());
 }
+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, 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, 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, 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) {
@@ -72,6 +88,16 @@ inline Vector<T> operator /(const Vector<T> &v, T s) {
        return Vector<T>(v.X() / s, v.Y() / s);
 }
 
+template<class T>
+inline bool operator ==(const Vector<T> &lhs, const Vector<T> &rhs) {
+       return lhs.X() == rhs.X() && lhs.Y() == rhs.Y();
+}
+
+template<class T>
+inline bool operator !=(const Vector<T> &lhs, const Vector<T> &rhs) {
+       return lhs.X() != rhs.X() || lhs.Y() != rhs.Y();
+}
+
 template<class T>
 inline std::ostream &operator <<(std::ostream &out, const Vector<T> &v) {
        out << '<' << v.X() << ", " << v.Y() << '>';