From 57ae596d887a4574bdac51c199d5ee38f9afa4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 2 May 2021 17:37:49 +0200 Subject: [PATCH] Math: don't call into RectangularMatrix privates from Matrix. Yes, it's one function call more this way, but it's cleaner and without duplicated code that's prone to bugs. --- src/Magnum/Math/Matrix.h | 2 +- src/Magnum/Math/RectangularMatrix.h | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Magnum/Math/Matrix.h b/src/Magnum/Math/Matrix.h index 53f749294..3b328e32d 100644 --- a/src/Magnum/Math/Matrix.h +++ b/src/Magnum/Math/Matrix.h @@ -83,7 +83,7 @@ template class Matrix: public RectangularMatrix constexpr /*implicit*/ Matrix(const Vector& first, const U&... next) noexcept: RectangularMatrix(first, next...) {} /** @brief Construct with one value for all elements */ - constexpr explicit Matrix(T value) noexcept: RectangularMatrix{typename Corrade::Containers::Implementation::GenerateSequence::Type{}, value} {} + constexpr explicit Matrix(T value) noexcept: RectangularMatrix{value} {} /** * @brief Construct from a matrix of a different type diff --git a/src/Magnum/Math/RectangularMatrix.h b/src/Magnum/Math/RectangularMatrix.h index 8a5671c5e..a7c56fd0d 100644 --- a/src/Magnum/Math/RectangularMatrix.h +++ b/src/Magnum/Math/RectangularMatrix.h @@ -497,21 +497,16 @@ template class RectangularMatrix { return *reinterpret_cast*>(data()); } - #ifndef DOXYGEN_GENERATING_OUTPUT - protected: - #else - private: - #endif - /* Implementation for RectangularMatrix::RectangularMatrix(T) and Matrix(T) */ - /* MSVC 2015 can't handle {} here */ - template constexpr explicit RectangularMatrix(Corrade::Containers::Implementation::Sequence, T value) noexcept: _data{Vector((static_cast(sequence), value))...} {} - private: /* These two needed to access _data to speed up debug builds, Matrix::ij() needs access to different Matrix sizes */ template friend class Matrix; template friend struct Implementation::MatrixDeterminant; + /* Implementation for RectangularMatrix::RectangularMatrix(T) and Matrix(T) */ + /* MSVC 2015 can't handle {} here */ + template constexpr explicit RectangularMatrix(Corrade::Containers::Implementation::Sequence, T value) noexcept: _data{Vector((static_cast(sequence), value))...} {} + /* Implementation for RectangularMatrix::fromDiagonal() and RectangularMatrix(IdentityInitT, T) */ template constexpr explicit RectangularMatrix(Corrade::Containers::Implementation::Sequence, const Vector& diagonal);