From 6551051817179b9573c9310f6d38b23251deac0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jakub=20Klinkovsk=C3=BD?= <klinkovsky@mmg.fjfi.cvut.cz>
Date: Thu, 30 Dec 2021 18:11:20 +0100
Subject: [PATCH] Added missing move-assignment operator to SparseMatrix

---
 src/TNL/Matrices/SparseMatrix.h   | 10 +++++++++-
 src/TNL/Matrices/SparseMatrix.hpp | 22 ++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/src/TNL/Matrices/SparseMatrix.h b/src/TNL/Matrices/SparseMatrix.h
index 76d47b50dc..1300a40d37 100644
--- a/src/TNL/Matrices/SparseMatrix.h
+++ b/src/TNL/Matrices/SparseMatrix.h
@@ -1044,13 +1044,21 @@ class SparseMatrix : public Matrix< Real, Device, Index, RealAllocator >
        */
 
       /**
-       * \brief Assignment of exactly the same matrix type.
+       * \brief Copy-assignment of exactly the same matrix type.
        *
        * \param matrix is input matrix for the assignment.
        * \return reference to this matrix.
        */
       SparseMatrix& operator=( const SparseMatrix& matrix );
 
+      /**
+       * \brief Move-assignment of exactly the same matrix type.
+       *
+       * \param matrix is input matrix for the assignment.
+       * \return reference to this matrix.
+       */
+      SparseMatrix& operator=( SparseMatrix&& matrix );
+
       /**
        * \brief Assignment of dense matrix
        *
diff --git a/src/TNL/Matrices/SparseMatrix.hpp b/src/TNL/Matrices/SparseMatrix.hpp
index b7df383b0a..4ae9990b56 100644
--- a/src/TNL/Matrices/SparseMatrix.hpp
+++ b/src/TNL/Matrices/SparseMatrix.hpp
@@ -831,6 +831,28 @@ operator=( const SparseMatrix& matrix )
    Matrix< Real, Device, Index >::operator=( matrix );
    this->columnIndexes = matrix.columnIndexes;
    this->segments = matrix.segments;
+   this->indexAllocator = matrix.indexAllocator;
+   this->view = this->getView();
+   return *this;
+}
+
+// move assignment
+template< typename Real,
+          typename Device,
+          typename Index,
+          typename MatrixType,
+          template< typename, typename, typename > class Segments,
+          typename ComputeReal,
+          typename RealAllocator,
+          typename IndexAllocator >
+SparseMatrix< Real, Device, Index, MatrixType, Segments, ComputeReal, RealAllocator, IndexAllocator >&
+SparseMatrix< Real, Device, Index, MatrixType, Segments, ComputeReal, RealAllocator, IndexAllocator >::
+operator=( SparseMatrix&& matrix )
+{
+   this->columnIndexes = std::move( matrix.columnIndexes );
+   this->segments = std::move( matrix.segments );
+   this->indexAllocator = std::move( matrix.indexAllocator );
+   Matrix< Real, Device, Index >::operator=( std::move( matrix ) );
    this->view = this->getView();
    return *this;
 }
-- 
GitLab