5#include <userver/formats/json/value.hpp>
6#include <userver/formats/parse/to.hpp>
7#include <userver/formats/serialize/to.hpp>
8#include <userver/utils/meta.hpp>
9#include <userver/utils/overloaded.hpp>
11USERVER_NAMESPACE_BEGIN
15template <
typename... T>
16auto& GetVariant(std::variant<T...>& arg) {
20template <
typename... T>
21const auto& GetVariant(
const std::variant<T...>& arg) {
26decltype(T().AsVariant()) GetVariant(T& arg) {
27 return arg.AsVariant();
30template <
typename... T>
32 const std::variant<
decltype(Parse(std::declval<formats::json::Value>(), formats::parse::To<T>{}))...>& value;
35template <
typename Value,
typename... T>
37 return value.
template As<std::variant<T...>>();
40template <
typename Value,
typename... T>
43 utils::Overloaded{[](
const formats::common::ParseType<Value, T>& item) {
44 return typename Value::Builder(T{item}).ExtractValue();