From 0a8067b16e14535174010ebdf138850215151a47 Mon Sep 17 00:00:00 2001 From: Marcel Koch Date: Fri, 9 Aug 2024 15:31:26 +0200 Subject: [PATCH] [mpi] define moved-from state for communicator --- include/ginkgo/core/base/mpi.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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. *