From c381388357a45e430020389b3131b4123f82a987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sat, 12 May 2012 12:41:24 +0200 Subject: [PATCH] Non-implicit conversion from Vector2 to Vector3. It shouldn't be implicit, because then it will be possible to autoconvert Vector4 from Vector2, which shouldn't be possible at all. But it shouldn't be explicit either, because this will not be possible then: Vector2 vec2; Vector3 vec3 = {vec2, 1.0}; Vector4 constructor from Vector3 stays the same, because the conversion is fairly common, nearly always with W set to 1. --- src/Math/Vector3.h | 2 +- src/Math/Vector4.h | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Math/Vector3.h b/src/Math/Vector3.h index be9934043..5653ca6de 100644 --- a/src/Math/Vector3.h +++ b/src/Math/Vector3.h @@ -68,7 +68,7 @@ template class Vector3: public Vector<3, T> { * @param other Two component vector * @param z Z / B value */ - inline constexpr Vector3(const Vector<2, T>& other, T z = T(0)): Vector<3, T>(other[0], other[1], z) {} + inline constexpr Vector3(const Vector<2, T>& other, T z): Vector<3, T>(other[0], other[1], z) {} inline constexpr T x() const { return (*this)[0]; } /**< @brief X component */ inline constexpr T y() const { return (*this)[1]; } /**< @brief Y component */ diff --git a/src/Math/Vector4.h b/src/Math/Vector4.h index 5b1e57418..2661f8344 100644 --- a/src/Math/Vector4.h +++ b/src/Math/Vector4.h @@ -53,6 +53,8 @@ template class Vector4: public Vector<4, T> { * @param other Three component vector * @param w W / A value */ + /* Not marked as explicit, because conversion from Vector3 to Vector4 + is fairly common, nearly always with W set to 1 */ inline constexpr Vector4(const Vector<3, T>& other, T w = T(1)): Vector<4, T>(other[0], other[1], other[2], w) {} inline constexpr T x() const { return (*this)[0]; } /**< @brief X component */