aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/ReturnByValue.h
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-05-30 13:43:08 -0400
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2010-05-30 13:43:08 -0400
commit641d968a9a7ed57a3b8a3f45dea43c5ee6717f97 (patch)
treeecadb1e03dc32f41bed89a72048496c60af31a5e /Eigen/src/Core/ReturnByValue.h
parent48b8ace517ac61a214cb7d2ad782c67c8a411744 (diff)
* Make ReturnByValue have the EvalBeforeAssigningBit and explicitly
enforce this mechanism (otherwise ReturnByValue bypasses it). (use .noalias() to get the old behavior.) * Remove a hack in Inverse, futile optimization for 2x2 expressions.
Diffstat (limited to 'Eigen/src/Core/ReturnByValue.h')
-rw-r--r--Eigen/src/Core/ReturnByValue.h11
1 files changed, 7 insertions, 4 deletions
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