From 39e7115ddddcc128801fd1f5d1e0b5b8130a349e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 23 Apr 2012 22:35:32 +0200 Subject: [PATCH] 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& operator=(const Vector3&); Vector3& 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 vec; vec = {0, 1, 2}; Other functions left untouched (they are still taking e.g. Vector instead of Vector3), because it saves one useless dummy constructor call (which would be visible in profiler, but without having any performance impacts altogether). --- src/Math/Matrix3.h | 2 +- src/Math/Matrix4.h | 2 +- src/Math/Vector2.h | 2 +- src/Math/Vector3.h | 2 +- src/Math/Vector4.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index e47b501ad..6fccee0dc 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -68,7 +68,7 @@ template class Matrix3: public Matrix { inline constexpr Matrix3(const Matrix& other): Matrix(other) {} /** @copydoc Matrix::operator=() */ - inline Matrix3& operator=(const Matrix& other) { + inline Matrix3& operator=(const Matrix3& other) { Matrix::operator=(other); return *this; } diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index a5d8eb4ed..a4f2e24cc 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -137,7 +137,7 @@ template class Matrix4: public Matrix { inline constexpr Matrix4(const Matrix& other): Matrix(other) {} /** @copydoc Matrix::operator=() */ - inline Matrix4& operator=(const Matrix& other) { + inline Matrix4& operator=(const Matrix4& other) { Matrix::operator=(other); return *this; } diff --git a/src/Math/Vector2.h b/src/Math/Vector2.h index 145f54072..9da40c2dd 100644 --- a/src/Math/Vector2.h +++ b/src/Math/Vector2.h @@ -57,7 +57,7 @@ template class Vector2: public Vector { inline void setY(T value) { (*this)[1] = value; } /**< @brief Set Y component */ /** @copydoc Vector::operator=() */ - inline Vector2& operator=(const Vector& other) { + inline Vector2& operator=(const Vector2& other) { Vector::operator=(other); return *this; } diff --git a/src/Math/Vector3.h b/src/Math/Vector3.h index b470f10db..4324f0977 100644 --- a/src/Math/Vector3.h +++ b/src/Math/Vector3.h @@ -98,7 +98,7 @@ template class Vector3: public Vector { inline void setB(T value) { setZ(value); } /**< @brief Set B component */ /** @copydoc Vector::operator=() */ - inline Vector3& operator=(const Vector& other) { + inline Vector3& operator=(const Vector3& other) { Vector::operator=(other); return *this; } diff --git a/src/Math/Vector4.h b/src/Math/Vector4.h index 0027db695..9342800e8 100644 --- a/src/Math/Vector4.h +++ b/src/Math/Vector4.h @@ -99,7 +99,7 @@ template class Vector4: public Vector { inline constexpr Vector3 rgb() const { return xyz(); } /** @copydoc Vector::operator=() */ - inline Vector4& operator=(const Vector& other) { + inline Vector4& operator=(const Vector4& other) { Vector::operator=(other); return *this; }