bug #54 - The big Map const-correctness changes

This commit is contained in:
Benoit Jacob
2010-12-10 02:09:58 -05:00
parent e736df3edd
commit 74cc42b22f
19 changed files with 311 additions and 113 deletions

View File

@@ -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();