Browse Source

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.
pull/518/head
Vladimír Vondruš 5 years ago
parent
commit
57ae596d88
  1. 2
      src/Magnum/Math/Matrix.h
  2. 13
      src/Magnum/Math/RectangularMatrix.h

2
src/Magnum/Math/Matrix.h

@ -83,7 +83,7 @@ template<std::size_t size, class T> class Matrix: public RectangularMatrix<size,
template<class ...U> constexpr /*implicit*/ Matrix(const Vector<size, T>& first, const U&... next) noexcept: RectangularMatrix<size, size, T>(first, next...) {}
/** @brief Construct with one value for all elements */
constexpr explicit Matrix(T value) noexcept: RectangularMatrix<size, size, T>{typename Corrade::Containers::Implementation::GenerateSequence<size>::Type{}, value} {}
constexpr explicit Matrix(T value) noexcept: RectangularMatrix<size, size, T>{value} {}
/**
* @brief Construct from a matrix of a different type

13
src/Magnum/Math/RectangularMatrix.h

@ -497,21 +497,16 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
return *reinterpret_cast<const Vector<rows*cols, T>*>(data());
}
#ifndef DOXYGEN_GENERATING_OUTPUT
protected:
#else
private:
#endif
/* Implementation for RectangularMatrix<cols, rows, T>::RectangularMatrix(T) and Matrix<size, T>(T) */
/* MSVC 2015 can't handle {} here */
template<std::size_t ...sequence> constexpr explicit RectangularMatrix(Corrade::Containers::Implementation::Sequence<sequence...>, T value) noexcept: _data{Vector<rows, T>((static_cast<void>(sequence), value))...} {}
private:
/* These two needed to access _data to speed up debug builds,
Matrix::ij() needs access to different Matrix sizes */
template<std::size_t, class> friend class Matrix;
template<std::size_t, class> friend struct Implementation::MatrixDeterminant;
/* Implementation for RectangularMatrix<cols, rows, T>::RectangularMatrix(T) and Matrix<size, T>(T) */
/* MSVC 2015 can't handle {} here */
template<std::size_t ...sequence> constexpr explicit RectangularMatrix(Corrade::Containers::Implementation::Sequence<sequence...>, T value) noexcept: _data{Vector<rows, T>((static_cast<void>(sequence), value))...} {}
/* Implementation for RectangularMatrix<cols, rows, T>::fromDiagonal() and RectangularMatrix<cols, rows, T>(IdentityInitT, T) */
template<std::size_t ...sequence> constexpr explicit RectangularMatrix(Corrade::Containers::Implementation::Sequence<sequence...>, const Vector<DiagonalSize, T>& diagonal);

Loading…
Cancel
Save