Added a move constructor and move assignment operator to Tensor and wrote some tests.

This commit is contained in:
Viktor Csomor
2018-02-07 19:10:54 +01:00
parent 3a2dc3869e
commit 000840cae0
3 changed files with 97 additions and 0 deletions

View File

@@ -398,6 +398,21 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
}
#if EIGEN_HAS_RVALUE_REFERENCES
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Tensor(Self&& other)
: Tensor()
{
m_storage.swap(other.m_storage);
}
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Tensor& operator=(Self&& other)
{
m_storage.swap(other.m_storage);
return *this;
}
#endif
EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE Tensor& operator=(const Tensor& other)
{