diff options
author | Hauke Heibel <hauke.heibel@gmail.com> | 2013-08-02 21:07:39 +0200 |
---|---|---|
committer | Hauke Heibel <hauke.heibel@gmail.com> | 2013-08-02 21:07:39 +0200 |
commit | 51b361b3bb40d547ecf39e4c2e90a806c56c9751 (patch) | |
tree | 603f48614f5973dd6ef006746bc66fa66807c81a /Eigen/src/Core/DenseStorage.h | |
parent | 7c99b38b7c34c5a031e347b81277e67ab9cfdd93 (diff) |
Ensure that (potentially aligned) stack objects are passed by reference.
Diffstat (limited to 'Eigen/src/Core/DenseStorage.h')
-rw-r--r-- | Eigen/src/Core/DenseStorage.h | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h index ae86b4d11..67507db28 100644 --- a/Eigen/src/Core/DenseStorage.h +++ b/Eigen/src/Core/DenseStorage.h @@ -118,7 +118,11 @@ template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseSt DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(internal::constructor_without_unaligned_array_assert()) {} DenseStorage(const DenseStorage& other) : m_data(other.m_data) {} - DenseStorage& operator=(DenseStorage other) { other.swap(*this); return *this; } + DenseStorage& operator=(const DenseStorage& other) + { + if (this != &other) m_data = other.m_data; + return *this; + } DenseStorage(DenseIndex,DenseIndex,DenseIndex) {} void swap(DenseStorage& other) { std::swap(m_data,other.m_data); } static DenseIndex rows(void) {return _Rows;} @@ -168,7 +172,16 @@ template<typename T, int Size, int _Options> class DenseStorage<T, Size, Dynamic DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {} DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {} - DenseStorage& operator=(DenseStorage other) { other.swap(*this); return *this; } + DenseStorage& operator=(const DenseStorage& other) + { + if (this != &other) + { + m_data = other.m_data; + m_rows = other.m_rows; + m_cols = other.m_cols; + } + other.swap(*this); return *this; + } DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) : m_rows(nbRows), m_cols(nbCols) {} void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); } @@ -190,7 +203,15 @@ template<typename T, int Size, int _Cols, int _Options> class DenseStorage<T, Si DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0) {} DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows) {} - DenseStorage& operator=(DenseStorage other) { other.swap(*this); return *this; } + DenseStorage& operator=(const DenseStorage& other) + { + if (this != &other) + { + m_data = other.m_data; + m_rows = other.m_rows; + } + return *this; + } DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex) : m_rows(nbRows) {} void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); } DenseIndex rows(void) const {return m_rows;} @@ -211,7 +232,15 @@ template<typename T, int Size, int _Rows, int _Options> class DenseStorage<T, Si DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(internal::constructor_without_unaligned_array_assert()), m_cols(0) {} DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_cols(other.m_cols) {} - DenseStorage& operator=(DenseStorage other) { other.swap(*this); return *this; } + DenseStorage& operator=(const DenseStorage& other) + { + if (this != &other) + { + m_data = other.m_data; + m_cols = other.m_cols; + } + return *this; + } DenseStorage(DenseIndex, DenseIndex, DenseIndex nbCols) : m_cols(nbCols) {} void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); } DenseIndex rows(void) const {return _Rows;} |