aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/MapBase.h
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-12-30 07:47:51 -0500
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-12-30 07:47:51 -0500
commit13867c15cca7716ff36c2ee2c9b37ebe2721cd9a (patch)
tree2c2b6bdbbbd11be47fb982b21a83e56511e3a3cc /Eigen/src/Core/MapBase.h
parent26c2afd55a16b2868e6776797e33c11bd28f3ffc (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/MapBase.h')
-rw-r--r--Eigen/src/Core/MapBase.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/Eigen/src/Core/MapBase.h b/Eigen/src/Core/MapBase.h
index d8ecdf2f4..826e4049d 100644
--- a/Eigen/src/Core/MapBase.h
+++ b/Eigen/src/Core/MapBase.h
@@ -201,15 +201,21 @@ template<typename Derived> class MapBase<Derived, WriteAccessors>
using Base::rowStride;
using Base::colStride;
+ typedef typename internal::conditional<
+ internal::is_lvalue<Derived>::value,
+ Scalar,
+ const Scalar
+ >::type ScalarWithConstIfNotLvalue;
+
inline const Scalar* data() const { return this->m_data; }
- inline Scalar* data() { return this->m_data; } // no const-cast here so non-const-correct code will give a compile error
+ inline ScalarWithConstIfNotLvalue* data() { return this->m_data; } // no const-cast here so non-const-correct code will give a compile error
- inline Scalar& coeffRef(Index row, Index col)
+ inline ScalarWithConstIfNotLvalue& coeffRef(Index row, Index col)
{
return this->m_data[col * colStride() + row * rowStride()];
}
- inline Scalar& coeffRef(Index index)
+ inline ScalarWithConstIfNotLvalue& coeffRef(Index index)
{
EIGEN_STATIC_ASSERT_LINEAR_ACCESS(Derived)
return this->m_data[index * innerStride()];