From 4a8258369a28eb340a1789bc05322475c7ace8f9 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 2 Sep 2009 13:37:15 +0200 Subject: [PATCH] much simpler fix for Matrix::swap --- Eigen/src/Core/Matrix.h | 39 +++++++-------------------------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/Eigen/src/Core/Matrix.h b/Eigen/src/Core/Matrix.h index cdc76c120..16c0ee4ac 100644 --- a/Eigen/src/Core/Matrix.h +++ b/Eigen/src/Core/Matrix.h @@ -490,8 +490,13 @@ class Matrix /** Override MatrixBase::swap() since for dynamic-sized matrices of same type it is enough to swap the * data pointers. */ - template - void swap(const MatrixBase& other); + using Base::swap; + inline void swap(Matrix& other) + { + ei_assert(matrix.rows() == other.rows() && matrix.cols() == other.cols()); + m_storage.swap(other.m_storage); + // FIXME what about using this->Base::swap(other); for fixed size ? + } /** \name Map * These are convenience functions returning Map objects. The Map() static functions return unaligned Map objects, @@ -650,38 +655,8 @@ class Matrix m_storage.data()[0] = x; m_storage.data()[1] = y; } - - template - friend struct ei_matrix_swap_impl; }; -template::ret> -struct ei_matrix_swap_impl -{ - static inline void run(MatrixType& matrix, MatrixBase& other) - { - matrix.base().swap(other); - } -}; - -template -struct ei_matrix_swap_impl -{ - static inline void run(MatrixType& matrix, MatrixBase& other) - { - ei_assert(matrix.rows() == other.rows() && matrix.cols() == other.cols()); - matrix.m_storage.swap(other.derived().m_storage); - } -}; - -template -template -inline void Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols>::swap(const MatrixBase& other) -{ - - ei_matrix_swap_impl::run(*this, *const_cast*>(&other)); -} /** \defgroup matrixtypedefs Global matrix typedefs *