mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-21 07:19:46 +08:00
fix compilation of code using e.g. Transpose<const Foo>::data() non-const-qualified. Same problem existed for coeffRef() and also in MapBase.h.
This commit is contained in:
parent
26c2afd55a
commit
13867c15cc
@ -201,15 +201,21 @@ template<typename Derived> class MapBase<Derived, WriteAccessors>
|
|||||||
using Base::rowStride;
|
using Base::rowStride;
|
||||||
using Base::colStride;
|
using Base::colStride;
|
||||||
|
|
||||||
inline const Scalar* data() const { return this->m_data; }
|
typedef typename internal::conditional<
|
||||||
inline Scalar* data() { return this->m_data; } // no const-cast here so non-const-correct code will give a compile error
|
internal::is_lvalue<Derived>::value,
|
||||||
|
Scalar,
|
||||||
|
const Scalar
|
||||||
|
>::type ScalarWithConstIfNotLvalue;
|
||||||
|
|
||||||
inline Scalar& coeffRef(Index row, Index col)
|
inline const Scalar* data() const { return this->m_data; }
|
||||||
|
inline ScalarWithConstIfNotLvalue* data() { return this->m_data; } // no const-cast here so non-const-correct code will give a compile error
|
||||||
|
|
||||||
|
inline ScalarWithConstIfNotLvalue& coeffRef(Index row, Index col)
|
||||||
{
|
{
|
||||||
return this->m_data[col * colStride() + row * rowStride()];
|
return this->m_data[col * colStride() + row * rowStride()];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Scalar& coeffRef(Index index)
|
inline ScalarWithConstIfNotLvalue& coeffRef(Index index)
|
||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT_LINEAR_ACCESS(Derived)
|
EIGEN_STATIC_ASSERT_LINEAR_ACCESS(Derived)
|
||||||
return this->m_data[index * innerStride()];
|
return this->m_data[index * innerStride()];
|
||||||
|
@ -120,16 +120,23 @@ template<typename MatrixType> class TransposeImpl<MatrixType,Dense>
|
|||||||
|
|
||||||
inline Index innerStride() const { return derived().nestedExpression().innerStride(); }
|
inline Index innerStride() const { return derived().nestedExpression().innerStride(); }
|
||||||
inline Index outerStride() const { return derived().nestedExpression().outerStride(); }
|
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 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)
|
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
||||||
return derived().nestedExpression().const_cast_derived().coeffRef(col, row);
|
return derived().nestedExpression().const_cast_derived().coeffRef(col, row);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Scalar& coeffRef(Index index)
|
inline ScalarWithConstIfNotLvalue& coeffRef(Index index)
|
||||||
{
|
{
|
||||||
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
EIGEN_STATIC_ASSERT_LVALUE(MatrixType)
|
||||||
return derived().nestedExpression().const_cast_derived().coeffRef(index);
|
return derived().nestedExpression().const_cast_derived().coeffRef(index);
|
||||||
|
Loading…
Reference in New Issue
Block a user