preCICE v3.1.1
Loading...
Searching...
No Matches
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 {
12namespace utils {
13
18struct MPIResult {
19 int code;
20
21 MPIResult() = default;
22
23 MPIResult(const MPIResult &other) = default;
24
25 MPIResult(int res)
26 : code(res) {}
27
29 {
30 code = other.code;
31 return *this;
32 }
33
34 operator bool() const
35 {
36 return code == MPI_SUCCESS;
37 }
38
40 {
42
43 int i;
44 MPI_Error_string(code, sm.data(), &i);
45 return sm.str();
46 }
47};
48
49} // namespace utils
50} // namespace precice
51
52#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
Main namespace of the precice library.
std::string message() const
Definition MPIResult.hpp:39
MPIResult(const MPIResult &other)=default
MPIResult & operator=(MPIResult other)
Definition MPIResult.hpp:28