fix += return by value like operations

This commit is contained in:
Gael Guennebaud
2010-09-06 11:51:42 +02:00
parent 62eb4dc99b
commit 9bb75937cc
5 changed files with 32 additions and 6 deletions

View File

@@ -62,8 +62,6 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp
typedef typename ei_packet_traits<Scalar>::type Packet;
using Base::operator=;
inline SelfCwiseBinaryOp(Lhs& xpr, const BinaryOp& func = BinaryOp()) : m_matrix(xpr), m_functor(func) {}
inline Index rows() const { return m_matrix.rows(); }
@@ -142,6 +140,15 @@ template<typename BinaryOp, typename Lhs, typename Rhs> class SelfCwiseBinaryOp
#endif
return *this;
}
// overloaded to honor evaluation of special matrices
// maybe another solution would be to not use SelfCwiseBinaryOp
// at first...
SelfCwiseBinaryOp& operator=(const Rhs& _rhs)
{
typename ei_nested<Rhs>::type rhs(_rhs);
return Base::operator=(rhs);
}
protected:
Lhs& m_matrix;