userver
C++ Async Framework
Loading...
Searching...
No Matches
serialize_variant.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/formats/json/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
/
json
/
value_builder
.
hpp
>
10
#
include
<
userver
/
formats
/
serialize
/
to
.
hpp
>
11
12
USERVER_NAMESPACE_BEGIN
13
14
namespace
formats::
serialize
{
15
16
template
<
typename
... Types>
17
formats::
json
::Value Serialize(
const
std::variant<Types...>& value,
18
To
<formats::
json
::Value>) {
19
return
std::visit(
20
[](
const
auto
& item) {
21
return
formats::
json
::ValueBuilder(item)
.
ExtractValue
(
)
;
22
},
23
value);
24
}
25
26
}
// namespace formats::serialize
27
28
USERVER_NAMESPACE_END
userver
formats
json
serialize_variant.hpp
Generated on Wed Oct 4 2023 12:18:41 for userver by
Doxygen
1.9.8