From 884a718b0a2faad2e34cd916704cbc6c2a23550e Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Mon, 15 Oct 2007 05:56:21 +0000 Subject: make shameless use of const_cast to reduce code redundancy. This means Eigen2 gives up enforcing constness. I really tried to enforce it, but it really was much hassle because our expression templates can be lvalues (not only rvalues) and so much code had to be written twice. --- src/Core/MatrixRef.h | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) (limited to 'src/Core/MatrixRef.h') diff --git a/src/Core/MatrixRef.h b/src/Core/MatrixRef.h index 7e6aea5e6..8fab9d06a 100644 --- a/src/Core/MatrixRef.h +++ b/src/Core/MatrixRef.h @@ -26,31 +26,6 @@ #ifndef EI_MATRIXREF_H #define EI_MATRIXREF_H -template class MatrixConstRef - : public Object > -{ - public: - typedef typename MatrixType::Scalar Scalar; - friend class Object; - - MatrixConstRef(const MatrixType& matrix) : m_matrix(matrix) {} - MatrixConstRef(const MatrixConstRef& other) : m_matrix(other.m_matrix) {} - ~MatrixConstRef() {} - - EI_INHERIT_ASSIGNMENT_OPERATORS(MatrixConstRef) - - private: - int _rows() const { return m_matrix.rows(); } - int _cols() const { return m_matrix.cols(); } - - const Scalar& _read(int row, int col) const - { - return m_matrix._read(row, col); - } - - const MatrixType& m_matrix; -}; - template class MatrixRef : public Object > { @@ -58,7 +33,7 @@ template class MatrixRef typedef typename MatrixType::Scalar Scalar; friend class Object; - MatrixRef(MatrixType& matrix) : m_matrix(matrix) {} + MatrixRef(const MatrixType& matrix) : m_matrix(*const_cast(&matrix)) {} MatrixRef(const MatrixRef& other) : m_matrix(other.m_matrix) {} ~MatrixRef() {} -- cgit v1.2.3