userver
C++ Async Framework
Loading...
Searching...
No Matches
optionals.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/utils/optionals.hpp
4
/// @brief Helper functions for std optionals
5
/// @ingroup userver_universal
6
7
#
include
<
optional
>
8
#
include
<
string
>
9
10
#
include
<
fmt
/
compile
.
h
>
11
#
include
<
fmt
/
format
.
h
>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
utils
{
16
17
/// Converts std::optional to a string, empty value represented as "--"
18
template
<
class
T>
19
std::string
ToString
(
const
std::optional<T>& from) {
20
return
from ? fmt::format(FMT_COMPILE(
" {}"
), *from) :
"--"
;
21
}
22
23
}
// namespace utils
24
25
USERVER_NAMESPACE_END
userver
utils
optionals.hpp
Generated on Wed Oct 4 2023 12:19:57 for userver by
Doxygen
1.9.8