From 6a2ebf5c3d625442ccb49a5277226788adcb538a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 28 Sep 2012 21:40:29 +0200 Subject: [PATCH] Fixed Vector, Point and Color constructors from smaller types. Currently, when accidentaly creating specialized Vector from smaller number of components than required, the error message isn't really helpful, as it stops on static assert on wrong number of arguments passed to RectangularMatrix: Vector3(0, 1); // static assert: wrong number of arguments passed to // RectangularMatrix<1, 2> -- wtf?! Now the first argument is Vector2/Vector3 instead of Vector<2>/Vector<3> and the error message now properly states that no matching constructor was found. --- src/Color.h | 2 +- src/Math/Point2D.h | 2 +- src/Math/Point3D.h | 2 +- src/Math/Vector3.h | 2 +- src/Math/Vector4.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Color.h b/src/Color.h index 30b5af324..4245f4ece 100644 --- a/src/Color.h +++ b/src/Color.h @@ -359,7 +359,7 @@ template class Color4: public Math::Vector4 { */ /* Not marked as explicit, because conversion from Color3 to Color4 is fairly common, nearly always with A set to 1 */ - inline constexpr Color4(const Math::Vector<3, T>& rgb, T a = Implementation::defaultAlpha()): Math::Vector4(rgb[0], rgb[1], rgb[2], a) {} + inline constexpr Color4(const Math::Vector3& rgb, T a = Implementation::defaultAlpha()): Math::Vector4(rgb[0], rgb[1], rgb[2], a) {} inline T& r() { return Math::Vector4::x(); } /**< @brief R component */ inline constexpr T r() const { return Math::Vector4::x(); } /**< @overload */ diff --git a/src/Math/Point2D.h b/src/Math/Point2D.h index a882e68ab..896332e65 100644 --- a/src/Math/Point2D.h +++ b/src/Math/Point2D.h @@ -57,7 +57,7 @@ template class Point2D: public Vector3 { * @param xy Two-component vector * @param z Z component */ - inline constexpr Point2D(const Vector<2, T>& xy, T z = T(1)): Vector3(xy, z) {} + inline constexpr Point2D(const Vector2& xy, T z = T(1)): Vector3(xy, z) {} /** * @brief Vector part of the point diff --git a/src/Math/Point3D.h b/src/Math/Point3D.h index 19c89aa75..511946b9b 100644 --- a/src/Math/Point3D.h +++ b/src/Math/Point3D.h @@ -58,7 +58,7 @@ template class Point3D: public Vector4 { * @param xyz Three-component vector * @param w W component */ - inline constexpr Point3D(const Vector<3, T>& xyz, T w = T(1)): Vector4(xyz, w) {} + inline constexpr Point3D(const Vector3& xyz, T w = T(1)): Vector4(xyz, w) {} /** * @brief Vector part of the point diff --git a/src/Math/Vector3.h b/src/Math/Vector3.h index 79a3a9075..373801918 100644 --- a/src/Math/Vector3.h +++ b/src/Math/Vector3.h @@ -124,7 +124,7 @@ template class Vector3: public Vector<3, T> { * @param xy Two-component vector * @param z Z component */ - inline constexpr Vector3(const Vector<2, T>& xy, T z): Vector<3, T>(xy[0], xy[1], z) {} + inline constexpr Vector3(const Vector2& xy, T z): Vector<3, T>(xy[0], xy[1], z) {} inline T& x() { return (*this)[0]; } /**< @brief X component */ inline constexpr T x() const { return (*this)[0]; } /**< @overload */ diff --git a/src/Math/Vector4.h b/src/Math/Vector4.h index e7b21e320..ef4eb762c 100644 --- a/src/Math/Vector4.h +++ b/src/Math/Vector4.h @@ -56,7 +56,7 @@ template class Vector4: public Vector<4, T> { * @param xyz Three-component vector * @param w W component */ - inline constexpr Vector4(const Vector<3, T>& xyz, T w): Vector<4, T>(xyz[0], xyz[1], xyz[2], w) {} + inline constexpr Vector4(const Vector3& xyz, T w): Vector<4, T>(xyz[0], xyz[1], xyz[2], w) {} inline T& x() { return (*this)[0]; } /**< @brief X component */ inline constexpr T x() const { return (*this)[0]; } /**< @overload */