diff options
author | Gael Guennebaud <g.gael@free.fr> | 2014-11-06 09:25:26 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2014-11-06 09:25:26 +0100 |
commit | 722916e19d86b224ec6c705e24d376def524154b (patch) | |
tree | f68ce5ba93b0ab12fbd838e6254b99086730901c /Eigen/src/Core/PlainObjectBase.h | |
parent | c6fefe5d8e3eda8af05c7dcb278551598dbb5d8e (diff) |
bug #903: clean swap API regarding extra enable_if parameters, and add failtests for swap
Diffstat (limited to 'Eigen/src/Core/PlainObjectBase.h')
-rw-r--r-- | Eigen/src/Core/PlainObjectBase.h | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h index 58fe0f6e0..06e326a05 100644 --- a/Eigen/src/Core/PlainObjectBase.h +++ b/Eigen/src/Core/PlainObjectBase.h @@ -795,23 +795,33 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type { Base::setConstant(val0); } - + template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> friend struct internal::matrix_swap_impl; - /** \internal generic implementation of swap for dense storage since for dynamic-sized matrices of same type it is enough to swap the - * data pointers. + public: + +#ifndef EIGEN_PARSED_BY_DOXYGEN + /** \internal + * \brief Override DenseBase::swap() since for dynamic-sized matrices + * of same type it is enough to swap the data pointers. */ template<typename OtherDerived> EIGEN_DEVICE_FUNC - void _swap(DenseBase<OtherDerived> const & other) + void swap(DenseBase<OtherDerived> & other) { enum { SwapPointers = internal::is_same<Derived, OtherDerived>::value && Base::SizeAtCompileTime==Dynamic }; - internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.const_cast_derived()); + internal::matrix_swap_impl<Derived, OtherDerived, bool(SwapPointers)>::run(this->derived(), other.derived()); } - - public: -#ifndef EIGEN_PARSED_BY_DOXYGEN + + /** \internal + * \brief const version forwarded to DenseBase::swap + */ + template<typename OtherDerived> + EIGEN_DEVICE_FUNC + void swap(DenseBase<OtherDerived> const & other) + { Base::swap(other.derived()); } + EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE void _check_template_params() { @@ -826,10 +836,9 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type && (Options & (DontAlign|RowMajor)) == Options), INVALID_MATRIX_TEMPLATE_PARAMETERS) } -#endif -private: - enum { ThisConstantIsPrivateInPlainObjectBase }; + enum { IsPlainObjectBase = 1 }; +#endif }; namespace internal { |