From 75b7d98665dd144c44d7a113c6613f5f998be626 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Wed, 22 Dec 2010 17:45:37 -0500 Subject: bug #54 - really fix const correctness except in Sparse --- Eigen/src/Core/Block.h | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'Eigen/src/Core/Block.h') diff --git a/Eigen/src/Core/Block.h b/Eigen/src/Core/Block.h index 3ab242537..00d5d8b4e 100644 --- a/Eigen/src/Core/Block.h +++ b/Eigen/src/Core/Block.h @@ -96,9 +96,13 @@ struct traits ? PacketAccessBit : 0, MaskAlignedBit = (InnerPanel && (OuterStrideAtCompileTime!=Dynamic) && ((OuterStrideAtCompileTime % packet_traits::size) == 0)) ? AlignedBit : 0, FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0, - Flags0 = traits::Flags & (HereditaryBits | MaskPacketAccessBit | LvalueBit | DirectAccessBit | MaskAlignedBit), - Flags1 = Flags0 | FlagsLinearAccessBit, - Flags = (Flags1 & ~RowMajorBit) | (IsRowMajor ? RowMajorBit : 0) + FlagsLvalueBit = is_lvalue::value ? LvalueBit : 0, + FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0, + Flags0 = traits::Flags & ( (HereditaryBits & ~RowMajorBit) | + DirectAccessBit | + MaskPacketAccessBit | + MaskAlignedBit), + Flags = Flags0 | FlagsLinearAccessBit | FlagsLvalueBit | FlagsRowMajorBit }; }; } @@ -162,6 +166,13 @@ template /** Column or Row constructor */ - inline Block(const XprType& xpr, Index i) - : Base(&xpr.const_cast_derived().coeffRef( + inline Block(XprType& xpr, Index i) + : Base(&xpr.coeffRef( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0, (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0), BlockRows==1 ? 1 : xpr.rows(), @@ -262,8 +281,8 @@ class Block /** Fixed-size constructor */ - inline Block(const XprType& xpr, Index startRow, Index startCol) - : Base(&xpr.const_cast_derived().coeffRef(startRow,startCol)), m_xpr(xpr) + inline Block(XprType& xpr, Index startRow, Index startCol) + : Base(&xpr.coeffRef(startRow,startCol)), m_xpr(xpr) { eigen_assert(startRow >= 0 && BlockRows >= 1 && startRow + BlockRows <= xpr.rows() && startCol >= 0 && BlockCols >= 1 && startCol + BlockCols <= xpr.cols()); @@ -272,10 +291,10 @@ class Block /** Dynamic-size constructor */ - inline Block(const XprType& xpr, + inline Block(XprType& xpr, Index startRow, Index startCol, Index blockRows, Index blockCols) - : Base(&xpr.const_cast_derived().coeffRef(startRow,startCol), blockRows, blockCols), + : Base(&xpr.coeffRef(startRow,startCol), blockRows, blockCols), m_xpr(xpr) { eigen_assert((RowsAtCompileTime==Dynamic || RowsAtCompileTime==blockRows) -- cgit v1.2.3