aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/Map.h
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-12-10 02:09:58 -0500
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-12-10 02:09:58 -0500
commit74cc42b22fbe1c05dcbedefb65ceabdec20da146 (patch)
tree08cbb408c2c75ae3af2950eca494e03dbe5966d1 /Eigen/src/Core/Map.h
parente736df3eddf0f2b8623653a66b8654f7770f03c8 (diff)
bug #54 - The big Map const-correctness changes
Diffstat (limited to 'Eigen/src/Core/Map.h')
-rw-r--r--Eigen/src/Core/Map.h22
1 files changed, 14 insertions, 8 deletions
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<typename PlainObjectType, int MapOptions, typename StrideType>
struct traits<Map<PlainObjectType, MapOptions, StrideType> >
- : public traits<PlainObjectType>
+ : public traits<typename internal::remove_const<PlainObjectType>::type>
{
+ typedef traits<typename internal::remove_const<PlainObjectType>::type> TraitsBase;
typedef typename PlainObjectType::Index Index;
typedef typename PlainObjectType::Scalar Scalar;
enum {
@@ -101,13 +102,15 @@ struct traits<Map<PlainObjectType, MapOptions, StrideType> >
|| HasNoOuterStride
|| ( OuterStrideAtCompileTime!=Dynamic
&& ((static_cast<int>(sizeof(Scalar))*OuterStrideAtCompileTime)%16)==0 ) ),
- Flags0 = traits<PlainObjectType>::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<PlainObjectType>::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<typename PlainObjectType, int MapOptions, typename StrideType> 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<typename PlainObjectType, int MapOptions, typename StrideType> 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<typename PlainObjectType, int MapOptions, typename StrideType> 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<typename PlainObjectType, int MapOptions, typename StrideType> 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();