diff options
author | Sebastien Boisvert <seb@boisvert.info> | 2020-06-11 23:43:25 +0000 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2020-06-11 23:43:25 +0000 |
commit | 39cbd6578fbf3a98d8a213c8ec3f5147557d065e (patch) | |
tree | cc04e0117d47268dbbf3a79cd851a7bcf7d5b1f0 /Eigen/src/Core/DenseStorage.h | |
parent | a7d2552af8b34f6befba9988c36fe5d9723892e6 (diff) |
Fix #1911: add benchmark for move semantics with fixed-size matrix
$ clang++ -O3 bench/bench_move_semantics.cpp -I. -std=c++11 \
-o bench_move_semantics
$ ./bench_move_semantics
float copy semantics: 1755.97 ms
float move semantics: 55.063 ms
double copy semantics: 2457.65 ms
double move semantics: 55.034 ms
Diffstat (limited to 'Eigen/src/Core/DenseStorage.h')
-rw-r--r-- | Eigen/src/Core/DenseStorage.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Eigen/src/Core/DenseStorage.h b/Eigen/src/Core/DenseStorage.h index a8bb8a624..6966513b3 100644 --- a/Eigen/src/Core/DenseStorage.h +++ b/Eigen/src/Core/DenseStorage.h @@ -200,6 +200,18 @@ template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseSt if (this != &other) m_data = other.m_data; return *this; } +#if EIGEN_HAS_RVALUE_REFERENCES + EIGEN_DEVICE_FUNC DenseStorage(DenseStorage&& other) EIGEN_NOEXCEPT + : m_data(std::move(other.m_data)) + { + } + EIGEN_DEVICE_FUNC DenseStorage& operator=(DenseStorage&& other) EIGEN_NOEXCEPT + { + if (this != &other) + m_data = std::move(other.m_data); + return *this; + } +#endif EIGEN_DEVICE_FUNC DenseStorage(Index size, Index rows, Index cols) { EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN({}) eigen_internal_assert(size==rows*cols && rows==_Rows && cols==_Cols); |