preCICE
v3.1.2
Loading...
Searching...
No Matches
src
utils
fmt.hpp
Go to the documentation of this file.
1
6
#pragma once
7
8
#include <
string
>
9
#include <
string_view
>
10
11
#include "fmt/format.h"
12
#include "fmt/ostream.h"
13
#include "
utils/fmtEigen.hpp
"
14
#include "
utils/fmtSTL.hpp
"
15
16
namespace
precice::utils
{
17
18
// pass through for string only
19
inline
std::string
format_or_error
(
std::string_view
str)
20
{
21
return
std::string
{str};
22
}
23
24
template
<
class
... A>
25
std::string
format_or_error
(
std::string_view
fmt, A &&... args)
26
{
27
try
{
28
return
fmt::vformat(fmt, fmt::make_format_args(args...));
29
}
catch
(
const
fmt::format_error &e) {
30
return
std::string
{
"fmt_error: "
} + e.what();
31
}
32
}
33
34
}
// namespace precice::utils
std::string
std::string_view
fmtEigen.hpp
fmtSTL.hpp
precice::utils
contains precice-related utilities.
Definition
PointToPointCommunicationTest.cpp:23
precice::utils::format_or_error
std::string format_or_error(std::string_view str)
Definition
fmt.hpp:19
string
string_view