preCICE v3.2.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MPIResult.hpp
Go to the documentation of this file.
1#include <ostream>
2#ifndef PRECICE_NO_MPI
3
4#pragma once
5
6#include <mpi.h>
7#include <ostream>
8
9#include "utils/String.hpp"
10
11namespace precice::utils {
12
17struct MPIResult {
18 int code;
19
20 MPIResult() = default;
21
22 MPIResult(const MPIResult &other) = default;
23
24 MPIResult(int res)
25 : code(res) {}
26
28 {
29 code = other.code;
30 return *this;
31 }
32
33 operator bool() const
34 {
35 return code == MPI_SUCCESS;
36 }
37
39 {
41
42 int i;
43 MPI_Error_string(code, sm.data(), &i);
44 return sm.str();
45 }
46};
47
48} // namespace precice::utils
49
50#endif
Utility class to build a string from C functions with output pointers and static maximum length.
Definition String.hpp:14
std::string str() const
Definition String.hpp:35
contains precice-related utilities.
std::string message() const
Definition MPIResult.hpp:38
MPIResult(const MPIResult &other)=default
MPIResult & operator=(MPIResult other)
Definition MPIResult.hpp:27