diff options
author | Gael Guennebaud <g.gael@free.fr> | 2014-10-07 18:29:28 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2014-10-07 18:29:28 +0200 |
commit | 57413492948d4c9dd6572f5bde6720b80122054a (patch) | |
tree | 22c8b070d5f929c32428e562505a27f704d978eb /Eigen/src/Core/TriangularMatrix.h | |
parent | 118b1113d9a4fa1a263597cdd699e237e5f2b4ac (diff) |
bug #882: fix various const-correctness issues with *View classes.
Diffstat (limited to 'Eigen/src/Core/TriangularMatrix.h')
-rw-r--r-- | Eigen/src/Core/TriangularMatrix.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/Eigen/src/Core/TriangularMatrix.h b/Eigen/src/Core/TriangularMatrix.h index 263d54485..055ed7514 100644 --- a/Eigen/src/Core/TriangularMatrix.h +++ b/Eigen/src/Core/TriangularMatrix.h @@ -173,7 +173,8 @@ struct traits<TriangularView<MatrixType, _Mode> > : traits<MatrixType> typedef MatrixType ExpressionType; enum { Mode = _Mode, - Flags = (MatrixTypeNestedCleaned::Flags & (HereditaryBits | LvalueBit) & (~(PacketAccessBit | DirectAccessBit | LinearAccessBit))) + FlagsLvalueBit = is_lvalue<MatrixType>::value ? LvalueBit : 0, + Flags = (MatrixTypeNestedCleaned::Flags & (HereditaryBits | FlagsLvalueBit) & (~(PacketAccessBit | DirectAccessBit | LinearAccessBit))) }; }; } @@ -213,7 +214,7 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView // FIXME This, combined with const_cast_derived in transpose() leads to a const-correctness loophole EIGEN_DEVICE_FUNC - explicit inline TriangularView(const MatrixType& matrix) : m_matrix(matrix) + explicit inline TriangularView(MatrixType& matrix) : m_matrix(matrix) {} using Base::operator=; @@ -229,14 +230,9 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView const NestedExpression& nestedExpression() const { return m_matrix; } EIGEN_DEVICE_FUNC NestedExpression& nestedExpression() { return *const_cast<NestedExpression*>(&m_matrix); } - - typedef TriangularView<MatrixConjugateReturnType,Mode> ConjugateReturnType; - /** \sa MatrixBase::conjugate() */ - EIGEN_DEVICE_FUNC - inline ConjugateReturnType conjugate() - { return ConjugateReturnType(m_matrix.conjugate()); } + /** \sa MatrixBase::conjugate() const */ - + typedef TriangularView<const MatrixConjugateReturnType,Mode> ConjugateReturnType; EIGEN_DEVICE_FUNC inline const ConjugateReturnType conjugate() const { return ConjugateReturnType(m_matrix.conjugate()); } @@ -253,7 +249,8 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView inline TransposeReturnType transpose() { EIGEN_STATIC_ASSERT_LVALUE(MatrixType) - return TransposeReturnType(m_matrix.const_cast_derived().transpose()); + typename MatrixType::TransposeReturnType tmp(m_matrix.const_cast_derived()); + return TransposeReturnType(tmp); } typedef TriangularView<const typename MatrixType::ConstTransposeReturnType,TransposeMode> ConstTransposeReturnType; @@ -392,6 +389,7 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularViewImpl<_Mat EIGEN_DEVICE_FUNC inline Scalar& coeffRef(Index row, Index col) { + EIGEN_STATIC_ASSERT_LVALUE(TriangularViewType); Base::check_coordinates_internal(row, col); return derived().nestedExpression().const_cast_derived().coeffRef(row, col); } |