From 8b69969fbf4789d05575b96e84dbdddfe8436d78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 16 Apr 2012 12:24:38 +0200 Subject: [PATCH] Explicit default Matrix constructor. Nothing like this should ever happen: 1*Vector3::yAxis() // 1 converted to true, converted to Matrix3. --- src/Math/Matrix.h | 2 +- src/Math/Matrix3.h | 2 +- src/Math/Matrix4.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index 8210035d8..743df7192 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -56,7 +56,7 @@ template class Matrix { * @brief Default constructor * @param identity Create identity matrix instead of zero matrix. */ - inline Matrix(bool identity = true): _data() { + inline explicit Matrix(bool identity = true): _data() { /** @todo constexpr how? */ if(identity) for(size_t i = 0; i != size; ++i) _data[size*i+i] = static_cast(1); diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index 2145e72c7..fab6ea6ef 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -38,7 +38,7 @@ template class Matrix3: public Matrix { } /** @copydoc Matrix::Matrix(bool) */ - inline constexpr Matrix3(bool identity = true): Matrix{ + inline constexpr explicit Matrix3(bool identity = true): Matrix{ /** @todo Make this in Matrix itself, after it will be constexpr */ identity ? 1.0f : 0.0f, 0.0f, 0.0f, 0.0f, identity ? 1.0f : 0.0f, 0.0f, diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index 633a7803b..4a2f15164 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -106,7 +106,7 @@ template class Matrix4: public Matrix { } /** @copydoc Matrix::Matrix(bool) */ - inline constexpr Matrix4(bool identity = true): Matrix{ + inline constexpr explicit Matrix4(bool identity = true): Matrix{ /** @todo Make this in Matrix itself, after it will be constexpr */ identity ? 1.0f : 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, identity ? 1.0f : 0.0f, 0.0f, 0.0f,