Browse Source

Prevent ambiguity in operator= in Matrix and Vector subclasses.

Because no operator= which took the class itself as argument (parent
class only), the compiler generated default assignment and assignment
move constructors, e.g.

    Vector3<T>& operator=(const Vector3<T>&);
    Vector3<T>& operator=(Vector3&&);

Resulting in conflicts when using assignment uniform initialization,
i.e. it wasn't possible to do things like this, but that's now fixed:

    Vector3<int> vec;
    vec = {0, 1, 2};

Other functions left untouched (they are still taking e.g. Vector<T,
3> instead of Vector3<T>), because it saves one useless dummy
constructor call (which would be visible in profiler, but without
having any performance impacts altogether).
vectorfields
Vladimír Vondruš 14 years ago
parent
commit
39e7115ddd
  1. 2
      src/Math/Matrix3.h
  2. 2
      src/Math/Matrix4.h
  3. 2
      src/Math/Vector2.h
  4. 2
      src/Math/Vector3.h
  5. 2
      src/Math/Vector4.h

2
src/Math/Matrix3.h

@ -68,7 +68,7 @@ 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 Matrix3<T>& operator=(const Matrix<T, 3>& other) {
inline Matrix3<T>& operator=(const Matrix3<T>& other) {
Matrix<T, 3>::operator=(other);
return *this;
}

2
src/Math/Matrix4.h

@ -137,7 +137,7 @@ 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 Matrix4<T>& operator=(const Matrix<T, 4>& other) {
inline Matrix4<T>& operator=(const Matrix4<T>& other) {
Matrix<T, 4>::operator=(other);
return *this;
}

2
src/Math/Vector2.h

@ -57,7 +57,7 @@ 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) {
inline Vector2<T>& operator=(const Vector2<T>& other) {
Vector<T, 2>::operator=(other);
return *this;
}

2
src/Math/Vector3.h

@ -98,7 +98,7 @@ 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) {
inline Vector3<T>& operator=(const Vector3<T>& other) {
Vector<T, 3>::operator=(other);
return *this;
}

2
src/Math/Vector4.h

@ -99,7 +99,7 @@ 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) {
inline Vector4<T>& operator=(const Vector4<T>& other) {
Vector<T, 4>::operator=(other);
return *this;
}

Loading…
Cancel
Save