From: Timo Heister Date: Wed, 11 Jun 2025 21:15:29 +0000 (-0400) Subject: add [[nodiscard]] to MPI helper functions X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26d379477841b3d4248ab6fce4339e2c1919f624;p=dealii.git add [[nodiscard]] to MPI helper functions I forgot to use the return value of Broadcast (assuming it works like MPI_Bcast). A nodiscard warning would have helped me find this bug earlier. --- diff --git a/include/deal.II/base/mpi.h b/include/deal.II/base/mpi.h index 43850e4025..423f26627f 100644 --- a/include/deal.II/base/mpi.h +++ b/include/deal.II/base/mpi.h @@ -1156,7 +1156,7 @@ namespace Utilities * communicator. */ template - std::vector + [[nodiscard]] std::vector all_gather(const MPI_Comm comm, const T &object_to_send); /** @@ -1175,7 +1175,7 @@ namespace Utilities * communicator. All other processes receive an empty vector. */ template - std::vector + [[nodiscard]] std::vector gather(const MPI_Comm comm, const T &object_to_send, const unsigned int root_process = 0); @@ -1195,7 +1195,7 @@ namespace Utilities * @return Every process receives an object from the root_process. */ template - T + [[nodiscard]] T scatter(const MPI_Comm comm, const std::vector &objects_to_send, const unsigned int root_process = 0); @@ -1239,7 +1239,7 @@ namespace Utilities * `MPI_Bcast` and return the result. */ template - T + [[nodiscard]] T broadcast(const MPI_Comm comm, const T &object_to_send, const unsigned int root_process = 0); @@ -1280,7 +1280,7 @@ namespace Utilities * single rank. On all other processes, the returned value is undefined. */ template - T + [[nodiscard]] T reduce(const T &local_value, const MPI_Comm comm, const std::function &combiner, @@ -1299,7 +1299,7 @@ namespace Utilities * by MPI. */ template == true>> - std::pair + [[nodiscard]] std::pair partial_and_total_sum(const T &value, const MPI_Comm comm); @@ -1313,7 +1313,7 @@ namespace Utilities * can be handled. */ template - T + [[nodiscard]] T all_reduce(const T &local_value, const MPI_Comm comm, const std::function &combiner);