diff --git a/include/ginkgo/core/base/mpi.hpp b/include/ginkgo/core/base/mpi.hpp index 636296465a2..862f145ae16 100644 --- a/include/ginkgo/core/base/mpi.hpp +++ b/include/ginkgo/core/base/mpi.hpp @@ -462,6 +462,22 @@ class communicator { return comm_out; } + communicator(const communicator& other) = default; + + communicator(communicator&& other) { *this = std::move(other); } + + communicator& operator=(const communicator& other) = default; + + communicator& operator=(communicator&& other) + { + if (this != &other) { + comm_ = std::exchange(other.comm_, + std::make_shared(MPI_COMM_NULL)); + force_host_buffer_ = other.force_host_buffer_; + } + return *this; + } + /** * Return the underlying MPI_Comm object. *