Browse Source

Fixed operator= in subclasses (return ref to itself, not parent).

Also operator= cannot be constexpr. I wonder why the compilers accepted
it at all.
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
cd5c4d6d0b
  1. 5
      src/Math/Matrix3.h
  2. 5
      src/Math/Matrix4.h
  3. 5
      src/Math/Vector2.h
  4. 5
      src/Math/Vector3.h
  5. 5
      src/Math/Vector4.h

5
src/Math/Matrix3.h

@ -68,7 +68,10 @@ template<class T> class Matrix3: public Matrix<T, 3> {
inline constexpr Matrix3(const Matrix<T, 3>& other): Matrix<T, 3>(other) {}
/** @copydoc Matrix::operator=() */
inline constexpr Matrix3<T>& operator=(const Matrix<T, 3>& other) { return Matrix<T, 3>::operator=(other); }
inline Matrix3<T>& operator=(const Matrix<T, 3>& other) {
Matrix<T, 3>::operator=(other);
return *this;
}
/** @copydoc Matrix::operator[](size_t) */
inline Vector3<T>& operator[](size_t col) { return Vector3<T>::from(Matrix<T, 3>::data()+col*3); }

5
src/Math/Matrix4.h

@ -137,7 +137,10 @@ template<class T> class Matrix4: public Matrix<T, 4> {
inline constexpr Matrix4(const Matrix<T, 4>& other): Matrix<T, 4>(other) {}
/** @copydoc Matrix::operator=() */
inline constexpr Matrix4<T>& operator=(const Matrix<T, 4>& other) { return Matrix<T, 4>::operator=(other); }
inline Matrix4<T>& operator=(const Matrix<T, 4>& other) {
Matrix<T, 4>::operator=(other);
return *this;
}
/** @copydoc Matrix::operator[](size_t) */
inline Vector4<T>& operator[](size_t col) { return Vector4<T>::from(Matrix<T, 4>::data()+col*4); }

5
src/Math/Vector2.h

@ -57,7 +57,10 @@ template<class T> class Vector2: public Vector<T, 2> {
inline void setY(T value) { (*this)[1] = value; } /**< @brief Set Y component */
/** @copydoc Vector::operator=() */
inline Vector2<T>& operator=(const Vector<T, 2>& other) { return Vector<T, 2>::operator=(other); }
inline Vector2<T>& operator=(const Vector<T, 2>& other) {
Vector<T, 2>::operator=(other);
return *this;
}
/** @copydoc Vector::operator*(T) const */
inline Vector2<T> operator*(T number) const { return Vector<T, 2>::operator*(number); }

5
src/Math/Vector3.h

@ -91,7 +91,10 @@ template<class T> class Vector3: public Vector<T, 3> {
inline void setB(T value) { setZ(value); } /**< @brief Set B component */
/** @copydoc Vector::operator=() */
inline Vector3<T>& operator=(const Vector<T, 3>& other) { return Vector<T, 3>::operator=(other); }
inline Vector3<T>& operator=(const Vector<T, 3>& other) {
Vector<T, 3>::operator=(other);
return *this;
}
/** @copydoc Vector::operator*(T) const */
inline Vector3<T> operator*(T number) const { return Vector<T, 3>::operator*(number); }

5
src/Math/Vector4.h

@ -99,7 +99,10 @@ template<class T> class Vector4: public Vector<T, 4> {
inline constexpr Vector3<T> rgb() const { return xyz(); }
/** @copydoc Vector::operator=() */
inline Vector4<T>& operator=(const Vector<T, 4>& other) { return Vector<T, 4>::operator=(other); }
inline Vector4<T>& operator=(const Vector<T, 4>& other) {
Vector<T, 4>::operator=(other);
return *this;
}
/** @copydoc Vector::operator*(T) const */
inline Vector4<T> operator*(T number) const { return Vector<T, 4>::operator*(number); }

Loading…
Cancel
Save