From 74cc42b22fbe1c05dcbedefb65ceabdec20da146 Mon Sep 17 00:00:00 2001 From: Benoit Jacob Date: Fri, 10 Dec 2010 02:09:58 -0500 Subject: bug #54 - The big Map const-correctness changes --- Eigen/src/Core/Map.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'Eigen/src/Core/Map.h') diff --git a/Eigen/src/Core/Map.h b/Eigen/src/Core/Map.h index d163e371a..0321f6669 100644 --- a/Eigen/src/Core/Map.h +++ b/Eigen/src/Core/Map.h @@ -80,8 +80,9 @@ namespace internal { template struct traits > - : public traits + : public traits::type> { + typedef traits::type> TraitsBase; typedef typename PlainObjectType::Index Index; typedef typename PlainObjectType::Scalar Scalar; enum { @@ -101,13 +102,15 @@ struct traits > || HasNoOuterStride || ( OuterStrideAtCompileTime!=Dynamic && ((static_cast(sizeof(Scalar))*OuterStrideAtCompileTime)%16)==0 ) ), - Flags0 = traits::Flags, + Flags0 = TraitsBase::Flags, Flags1 = IsAligned ? (int(Flags0) | AlignedBit) : (int(Flags0) & ~AlignedBit), - Flags2 = HasNoStride ? int(Flags1) : int(Flags1 & ~LinearAccessBit), - Flags = KeepsPacketAccess ? int(Flags2) : (int(Flags2) & ~PacketAccessBit) + Flags2 = (bool(HasNoStride) || bool(PlainObjectType::IsVectorAtCompileTime)) + ? int(Flags1) : int(Flags1 & ~LinearAccessBit), + Flags3 = internal::is_const::value ? (int(Flags2) & ~LvalueBit) : int(Flags2), + Flags = KeepsPacketAccess ? int(Flags3) : (int(Flags3) & ~PacketAccessBit) }; private: - enum { Options }; // Expressions don't support Options + enum { Options }; // Expressions don't have Options }; } @@ -120,6 +123,9 @@ template class Ma EIGEN_DENSE_PUBLIC_INTERFACE(Map) + typedef typename Base::PointerType PointerType; + + inline Index innerStride() const { return StrideType::InnerStrideAtCompileTime != 0 ? m_stride.inner() : 1; @@ -138,7 +144,7 @@ template class Ma * \param data pointer to the array to map * \param stride optional Stride object, passing the strides. */ - inline Map(const Scalar* data, const StrideType& stride = StrideType()) + inline Map(PointerType data, const StrideType& stride = StrideType()) : Base(data), m_stride(stride) { PlainObjectType::Base::_check_template_params(); @@ -150,7 +156,7 @@ template class Ma * \param size the size of the vector expression * \param stride optional Stride object, passing the strides. */ - inline Map(const Scalar* data, Index size, const StrideType& stride = StrideType()) + inline Map(PointerType data, Index size, const StrideType& stride = StrideType()) : Base(data, size), m_stride(stride) { PlainObjectType::Base::_check_template_params(); @@ -163,7 +169,7 @@ template class Ma * \param cols the number of columns of the matrix expression * \param stride optional Stride object, passing the strides. */ - inline Map(const Scalar* data, Index rows, Index cols, const StrideType& stride = StrideType()) + inline Map(PointerType data, Index rows, Index cols, const StrideType& stride = StrideType()) : Base(data, rows, cols), m_stride(stride) { PlainObjectType::Base::_check_template_params(); -- cgit v1.2.3