userver
C++ Async Framework
Loading...
Searching...
No Matches
variant.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/formats/serialize/variant.hpp
4
/// @brief Serializers for std::variant
5
/// @ingroup userver_universal userver_formats_serialize
6
7
#
include
<
variant
>
8
9
#
include
<
userver
/
formats
/
serialize
/
to
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
formats::
serialize
{
14
15
template
<
typename
Value,
typename
... Types>
16
Value Serialize(
const
std::variant<Types...>& value,
To
<Value>) {
17
return
std::visit(
18
[](
const
auto
& item) {
19
return
typename
Value::Builder(item).ExtractValue();
20
},
21
value);
22
}
23
24
}
// namespace formats::serialize
25
26
USERVER_NAMESPACE_END
userver
formats
serialize
variant.hpp
Generated on Thu Sep 5 2024 11:24:37 for userver by
Doxygen
1.10.0