diff --git a/src/Math/Matrix.h b/src/Math/Matrix.h index a6a26ef9f..29903db66 100644 --- a/src/Math/Matrix.h +++ b/src/Math/Matrix.h @@ -72,6 +72,7 @@ template class Matrix { * @param next Next column vectors */ template inline constexpr static Matrix from(const Vector& first, const U&... next) { + static_assert(sizeof...(next)+1 == size, "Improper number of arguments passed to Matrix from Vector constructor"); return from(typename Implementation::GenerateSequence::Type(), first, next...); } @@ -100,10 +101,6 @@ template class Matrix { _data[size*i+i] = value; } - #ifndef DOXYGEN_GENERATING_OUTPUT - template explicit Matrix(U) = delete; - #endif - /** * @brief Initializer-list constructor * @param first First value @@ -112,7 +109,9 @@ template class Matrix { * Note that the values are in column-major order. */ #ifndef DOXYGEN_GENERATING_OUTPUT - template inline constexpr Matrix(T first, U... next): _data{first, next...} {} + template inline constexpr Matrix(T first, U... next): _data{first, next...} { + static_assert(sizeof...(next)+1 == size*size, "Improper number of arguments passed to Matrix constructor"); + } #else template inline constexpr Matrix(T first, U... next); #endif diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index e82da033d..eede7cce6 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -37,10 +37,6 @@ template class Matrix3: public Matrix<3, T> { 0.0f, 0.0f, value ) {} - #ifndef DOXYGEN_GENERATING_OUTPUT - template explicit Matrix3(U) = delete; - #endif - /** @copydoc Matrix::Matrix(T, U...) */ #ifndef DOXYGEN_GENERATING_OUTPUT template inline constexpr Matrix3(T first, U... next): Matrix<3, T>(first, next...) {} diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index ee29378a2..8fb94c644 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -105,10 +105,6 @@ template class Matrix4: public Matrix<4, T> { 0.0f, 0.0f, 0.0f, value ) {} - #ifndef DOXYGEN_GENERATING_OUTPUT - template explicit Matrix4(U) = delete; - #endif - /** @copydoc Matrix::Matrix(T, U...) */ #ifndef DOXYGEN_GENERATING_OUTPUT template inline constexpr Matrix4(T first, U... next): Matrix<4, T>(first, next...) {} diff --git a/src/Math/Vector.h b/src/Math/Vector.h index 2f34a0fa2..9007ce6f4 100644 --- a/src/Math/Vector.h +++ b/src/Math/Vector.h @@ -91,7 +91,9 @@ template class Vector { * @param next Next values */ #ifndef DOXYGEN_GENERATING_OUTPUT - template inline constexpr Vector(T first, U... next): _data{first, next...} {} + template inline constexpr Vector(T first, U... next): _data{first, next...} { + static_assert(sizeof...(next)+1 == size, "Improper number of arguments passed to Vector constructor"); + } #else template inline constexpr Vector(T first, U... next); #endif