diff options
author | Gael Guennebaud <g.gael@free.fr> | 2013-10-16 12:07:33 +0200 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2013-10-16 12:07:33 +0200 |
commit | b433fb28576af729251594dbccd659607be44280 (patch) | |
tree | 603aab2d17faf733c3a885c6e2acb013ac627ac0 /Eigen/src/Core/PlainObjectBase.h | |
parent | 2c0303c89eb4c1b979c6dcd2379c9d3f98ba4c99 (diff) |
Allow .conservativeResize(rows,cols) on vectors
Diffstat (limited to 'Eigen/src/Core/PlainObjectBase.h')
-rw-r--r-- | Eigen/src/Core/PlainObjectBase.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h index e9aa3a88c..1a4c19233 100644 --- a/Eigen/src/Core/PlainObjectBase.h +++ b/Eigen/src/Core/PlainObjectBase.h @@ -47,7 +47,10 @@ template<> struct check_rows_cols_for_overflow<Dynamic> { } }; -template <typename Derived, typename OtherDerived = Derived, bool IsVector = bool(Derived::IsVectorAtCompileTime)> struct conservative_resize_like_impl; +template <typename Derived, + typename OtherDerived = Derived, + bool IsVector = bool(Derived::IsVectorAtCompileTime) && bool(OtherDerived::IsVectorAtCompileTime)> +struct conservative_resize_like_impl; template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> struct matrix_swap_impl; @@ -682,8 +685,10 @@ private: enum { ThisConstantIsPrivateInPlainObjectBase }; }; +namespace internal { + template <typename Derived, typename OtherDerived, bool IsVector> -struct internal::conservative_resize_like_impl +struct conservative_resize_like_impl { typedef typename Derived::Index Index; static void run(DenseBase<Derived>& _this, Index rows, Index cols) @@ -743,11 +748,14 @@ struct internal::conservative_resize_like_impl } }; -namespace internal { - +// Here, the specialization for vectors inherits from the general matrix case +// to allow calling .conservativeResize(rows,cols) on vectors. template <typename Derived, typename OtherDerived> struct conservative_resize_like_impl<Derived,OtherDerived,true> + : conservative_resize_like_impl<Derived,OtherDerived,false> { + using conservative_resize_like_impl<Derived,OtherDerived,false>::run; + typedef typename Derived::Index Index; static void run(DenseBase<Derived>& _this, Index size) { |