diff options
author | 2010-12-30 07:47:51 -0500 | |
---|---|---|
committer | 2010-12-30 07:47:51 -0500 | |
commit | 13867c15cca7716ff36c2ee2c9b37ebe2721cd9a (patch) | |
tree | 2c2b6bdbbbd11be47fb982b21a83e56511e3a3cc /Eigen/src/Core/Transpose.h | |
parent | 26c2afd55a16b2868e6776797e33c11bd28f3ffc (diff) |
fix compilation of code using e.g. Transpose<const Foo>::data() non-const-qualified. Same problem existed for coeffRef() and also in MapBase.h.
Diffstat (limited to 'Eigen/src/Core/Transpose.h')
-rw-r--r-- | Eigen/src/Core/Transpose.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Eigen/src/Core/Transpose.h b/Eigen/src/Core/Transpose.h index 1c9403eba..a5687790f 100644 --- a/Eigen/src/Core/Transpose.h +++ b/Eigen/src/Core/Transpose.h @@ -120,16 +120,23 @@ template<typename MatrixType> class TransposeImpl<MatrixType,Dense> inline Index innerStride() const { return derived().nestedExpression().innerStride(); } inline Index outerStride() const { return derived().nestedExpression().outerStride(); } - inline Scalar* data() { return derived().nestedExpression().data(); } + + typedef typename internal::conditional< + internal::is_lvalue<MatrixType>::value, + Scalar, + const Scalar + >::type ScalarWithConstIfNotLvalue; + + inline ScalarWithConstIfNotLvalue* data() { return derived().nestedExpression().data(); } inline const Scalar* data() const { return derived().nestedExpression().data(); } - inline Scalar& coeffRef(Index row, Index col) + inline ScalarWithConstIfNotLvalue& coeffRef(Index row, Index col) { EIGEN_STATIC_ASSERT_LVALUE(MatrixType) return derived().nestedExpression().const_cast_derived().coeffRef(col, row); } - inline Scalar& coeffRef(Index index) + inline ScalarWithConstIfNotLvalue& coeffRef(Index index) { EIGEN_STATIC_ASSERT_LVALUE(MatrixType) return derived().nestedExpression().const_cast_derived().coeffRef(index); |