diff options
author | Gael Guennebaud <g.gael@free.fr> | 2015-12-09 15:47:08 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2015-12-09 15:47:08 +0100 |
commit | dc73430d4b49023ae4a19f9e8b35c64742f528fc (patch) | |
tree | 6a93c123c9f62ac101bd986c45cd980baba48633 /Eigen/src/Core/PlainObjectBase.h | |
parent | 1257fbd2f9a188340c29e88232c4da99b62dcc72 (diff) |
bug #1074: forbid the creation of PlainObjectBase object by making its ctor protected
Diffstat (limited to 'Eigen/src/Core/PlainObjectBase.h')
-rw-r--r-- | Eigen/src/Core/PlainObjectBase.h | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h index 6f1350dc0..1225e85b4 100644 --- a/Eigen/src/Core/PlainObjectBase.h +++ b/Eigen/src/Core/PlainObjectBase.h @@ -449,6 +449,10 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type return Base::operator=(func); } + // Prevent user from trying to instantiate PlainObjectBase objects + // by making all its constructor protected. See bug 1074. + protected: + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase() : m_storage() { @@ -495,17 +499,6 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type // EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED } - /** \copydoc MatrixBase::operator=(const EigenBase<OtherDerived>&) - */ - template<typename OtherDerived> - EIGEN_DEVICE_FUNC - EIGEN_STRONG_INLINE Derived& operator=(const EigenBase<OtherDerived> &other) - { - _resize_to_match(other); - Base::operator=(other.derived()); - return this->derived(); - } - /** \sa PlainObjectBase::operator=(const EigenBase<OtherDerived>&) */ template<typename OtherDerived> EIGEN_DEVICE_FUNC @@ -519,7 +512,7 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type /** \sa PlainObjectBase::operator=(const EigenBase<OtherDerived>&) */ template<typename OtherDerived> - EIGEN_DEVICE_FUNC + EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PlainObjectBase(const EigenBase<OtherDerived> &other) : m_storage() { @@ -538,6 +531,19 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type other.evalTo(this->derived()); } + public: + + /** \copydoc MatrixBase::operator=(const EigenBase<OtherDerived>&) + */ + template<typename OtherDerived> + EIGEN_DEVICE_FUNC + EIGEN_STRONG_INLINE Derived& operator=(const EigenBase<OtherDerived> &other) + { + _resize_to_match(other); + Base::operator=(other.derived()); + return this->derived(); + } + /** \name Map * These are convenience functions returning Map objects. The Map() static functions return unaligned Map objects, * while the AlignedMap() functions return aligned Map objects and thus should be called only with 16-byte-aligned |