mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
fix bugs caused by default copy constructors being called. valgrind,
you saved my life.
This commit is contained in:
@@ -73,29 +73,30 @@ class Matrix : public EigenBase<_Scalar, Matrix<_Scalar, _Rows, _Cols> >,
|
||||
|
||||
public:
|
||||
template<typename OtherDerived>
|
||||
Matrix& operator=(const EigenBase<Scalar, OtherDerived> &other)
|
||||
Matrix& operator=(const EigenBase<Scalar, OtherDerived>& other)
|
||||
{
|
||||
resize(other.rows(), other.cols());
|
||||
return Base::operator=(other);
|
||||
}
|
||||
Matrix& operator=(const Matrix& other)
|
||||
{
|
||||
resize(other.rows(), other.cols());
|
||||
return Base::operator=(other);
|
||||
}
|
||||
|
||||
template<typename OtherDerived>
|
||||
Matrix& operator+=(const EigenBase<Scalar, OtherDerived> &other)
|
||||
{
|
||||
return Base::operator+=(other);
|
||||
}
|
||||
template<typename OtherDerived>
|
||||
Matrix& operator-=(const EigenBase<Scalar, OtherDerived> &other)
|
||||
{
|
||||
return Base::operator-=(other);
|
||||
}
|
||||
|
||||
INHERIT_ASSIGNMENT_OPERATOR(Matrix, +=)
|
||||
INHERIT_ASSIGNMENT_OPERATOR(Matrix, -=)
|
||||
|
||||
explicit Matrix(int rows = 1, int cols = 1) : Storage(rows, cols) {}
|
||||
template<typename OtherDerived>
|
||||
Matrix(const EigenBase<Scalar, OtherDerived>& other) : Storage(other.rows(), other.cols())
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
Matrix(const Matrix& other) : Storage(other.rows(), other.cols())
|
||||
{
|
||||
*this = other;
|
||||
}
|
||||
~Matrix() {}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user