Skip to content

# Unvanquished/Unvanquished

Fix compound assignment operators for vectors

• Loading branch information...
Amanieu committed Apr 18, 2015
1 parent bd25e62 commit 212348d22ef2cb98b89487d7f524e0caa45497f9
Showing with 24 additions and 24 deletions.
1. +24 −24 src/common/math/Vector.h
 @@ -123,12 +123,12 @@ namespace Math { Vector operator/(Vector other) const {return this->Apply2([](Type a, Type b) {return a / b;}, other);} // Compound arithmetic operators Vector& operator+=(Vector other) {return *this = *this + other;} Vector& operator-=(Vector other) {return *this = *this - other;} Vector& operator*=(Type x) {return *this = *this * x;} Vector& operator*=(Vector other) {return *this = *this * other;} Vector& operator/=(Type x) {return *this = *this / x;} Vector& operator/=(Vector other) {return *this = *this / other;} Vector& operator+=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) + other;} Vector& operator-=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) - other;} Vector& operator*=(Type x) {return static_cast&>(*this) = static_cast&>(*this) * x;} Vector& operator*=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) * other;} Vector& operator/=(Type x) {return static_cast&>(*this) = static_cast&>(*this) / x;} Vector& operator/=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) / other;} }; template class VectorOps::value>>: public VectorBase { public: @@ -153,14 +153,14 @@ namespace Math { Vector operator%(Vector other) const {return this->Apply2([](Type a, Type b) {return a % b;}, other);} // Compound arithmetic operators Vector& operator+=(Vector other) {return *this = *this + other;} Vector& operator-=(Vector other) {return *this = *this - other;} Vector& operator*=(Type x) {return *this = *this * x;} Vector& operator*=(Vector other) {return *this = *this * other;} Vector& operator/=(Type x) {return *this = *this / x;} Vector& operator/=(Vector other) {return *this = *this / other;} Vector& operator%=(Type x) {return *this = *this % x;} Vector& operator%=(Vector other) {return *this = *this % other;} Vector& operator+=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) + other;} Vector& operator-=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) - other;} Vector& operator*=(Type x) {return static_cast&>(*this) = static_cast&>(*this) * x;} Vector& operator*=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) * other;} Vector& operator/=(Type x) {return static_cast&>(*this) = static_cast&>(*this) / x;} Vector& operator/=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) / other;} Vector& operator%=(Type x) {return static_cast&>(*this) = static_cast&>(*this) % x;} Vector& operator%=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) % other;} // Bitwise operators Vector operator~() const {return this->Apply([](Type a) {return ~a;});} @@ -173,13 +173,13 @@ namespace Math { Vector operator>>(Vector other) const {return this->Apply2([](Type a, Type b) {return a >> b;}, other);} // Compound bitwise operators Vector& operator&=(Vector other) {return *this = *this & other;} Vector& operator|=(Vector other) {return *this = *this | other;} Vector& operator^=(Vector other) {return *this = *this ^ other;} Vector& operator<<=(Type x) {return *this = *this << x;} Vector& operator<<=(Vector other) {return *this = *this << other;} Vector& operator>>=(Type x) {return *this = *this >> x;} Vector& operator>>=(Vector other) {return *this = *this >> other;} Vector& operator&=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) & other;} Vector& operator|=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) | other;} Vector& operator^=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) ^ other;} Vector& operator<<=(Type x) {return static_cast&>(*this) = static_cast&>(*this) << x;} Vector& operator<<=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) << other;} Vector& operator>>=(Type x) {return static_cast&>(*this) = static_cast&>(*this) >> x;} Vector& operator>>=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) >> other;} }; template class VectorOps: public VectorBase { public: @@ -194,9 +194,9 @@ namespace Math { Vector operator^(Vector other) const {return this->Apply2([](bool a, bool b) {return a != b;}, other);} // Compound bitwise operators Vector& operator&=(Vector other) {return *this = *this & other;} Vector& operator|=(Vector other) {return *this = *this | other;} Vector& operator^=(Vector other) {return *this = *this ^ other;} Vector& operator&=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) & other;} Vector& operator|=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) | other;} Vector& operator^=(Vector other) {return static_cast&>(*this) = static_cast&>(*this) ^ other;} // Group testing bool All() const {return this->Reduce(true, [](bool a, bool b) {return a && b;});}

#### 0 comments on commit `212348d`

Please sign in to comment.
You can’t perform that action at this time.