diff options
Diffstat (limited to 'Eigen/src/Core')
-rw-r--r-- | Eigen/src/Core/NoAlias.h | 10 | ||||
-rw-r--r-- | Eigen/src/Core/ReturnByValue.h | 11 |
2 files changed, 15 insertions, 6 deletions
diff --git a/Eigen/src/Core/NoAlias.h b/Eigen/src/Core/NoAlias.h index 30ddbeb3c..0542571e2 100644 --- a/Eigen/src/Core/NoAlias.h +++ b/Eigen/src/Core/NoAlias.h @@ -45,12 +45,18 @@ class NoAlias public: NoAlias(ExpressionType& expression) : m_expression(expression) {} - /** Behaves like MatrixBase::lazyAssign(other) - * \sa MatrixBase::lazyAssign() */ + /* \sa MatrixBase::lazyAssign() */ template<typename OtherDerived> EIGEN_STRONG_INLINE ExpressionType& operator=(const StorageBase<OtherDerived>& other) { return m_expression.lazyAssign(other.derived()); } + template<typename OtherDerived> + EIGEN_STRONG_INLINE ExpressionType& operator=(const ReturnByValue<OtherDerived>& other) + { + other.evalTo(m_expression); + return m_expression; + } + /** \sa MatrixBase::operator+= */ template<typename OtherDerived> EIGEN_STRONG_INLINE ExpressionType& operator+=(const StorageBase<OtherDerived>& other) diff --git a/Eigen/src/Core/ReturnByValue.h b/Eigen/src/Core/ReturnByValue.h index 986bab54d..b2e581c70 100644 --- a/Eigen/src/Core/ReturnByValue.h +++ b/Eigen/src/Core/ReturnByValue.h @@ -36,9 +36,9 @@ struct ei_traits<ReturnByValue<Derived> > enum { // We're disabling the DirectAccess because e.g. the constructor of // the Block-with-DirectAccess expression requires to have a coeffRef method. - // Also, we don't want to have to implement the stride stuff. + // FIXME this should be fixed so we can have DirectAccessBit here. Flags = (ei_traits<typename ei_traits<Derived>::ReturnType>::Flags - | EvalBeforeNestingBit) & ~DirectAccessBit + | EvalBeforeNestingBit | EvalBeforeAssigningBit) & ~DirectAccessBit }; }; @@ -83,8 +83,11 @@ template<typename Derived> template<typename OtherDerived> Derived& DenseBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other) { - other.evalTo(derived()); - return derived(); + // since we're by-passing the mechanisms in Assign.h, we implement here the EvalBeforeAssigningBit. + // override by using .noalias(), see corresponding operator= in NoAlias. + typename Derived::PlainObject result(rows(), cols()); + other.evalTo(result); + return (derived() = result); } #endif // EIGEN_RETURNBYVALUE_H |