relax Map const correctness in eigen2 support stages <= 3

introduce new 'strict' stage 4
This commit is contained in:
Benoit Jacob
2011-01-21 10:42:19 -05:00
parent 54dfcdf86e
commit 30de1651d3
3 changed files with 23 additions and 13 deletions

View File

@@ -124,7 +124,13 @@ template<typename PlainObjectType, int MapOptions, typename StrideType> class Ma
EIGEN_DENSE_PUBLIC_INTERFACE(Map)
typedef typename Base::PointerType PointerType;
#if EIGEN2_SUPPORT_STAGE <= STAGE3_FULL_EIGEN3_API
typedef const Scalar* PointerArgType;
inline PointerType cast_to_pointer_type(PointerArgType ptr) { return const_cast<PointerType>(ptr); }
#else
typedef PointerType PointerArgType;
inline PointerType cast_to_pointer_type(PointerArgType ptr) { return ptr; }
#endif
inline Index innerStride() const
{
@@ -144,8 +150,8 @@ 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(PointerType data, const StrideType& stride = StrideType())
: Base(data), m_stride(stride)
inline Map(PointerArgType data, const StrideType& stride = StrideType())
: Base(cast_to_pointer_type(data)), m_stride(stride)
{
PlainObjectType::Base::_check_template_params();
}
@@ -156,8 +162,8 @@ 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(PointerType data, Index size, const StrideType& stride = StrideType())
: Base(data, size), m_stride(stride)
inline Map(PointerArgType data, Index size, const StrideType& stride = StrideType())
: Base(cast_to_pointer_type(data), size), m_stride(stride)
{
PlainObjectType::Base::_check_template_params();
}
@@ -169,8 +175,8 @@ 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(PointerType data, Index rows, Index cols, const StrideType& stride = StrideType())
: Base(data, rows, cols), m_stride(stride)
inline Map(PointerArgType data, Index rows, Index cols, const StrideType& stride = StrideType())
: Base(cast_to_pointer_type(data), rows, cols), m_stride(stride)
{
PlainObjectType::Base::_check_template_params();
}