10#include <boost/pfr/core.hpp>
11#include <boost/pfr/tuple_size.hpp>
13#include <userver/dump/operations.hpp>
15USERVER_NAMESPACE_BEGIN
29template <
typename T, std::size_t... Indices>
30constexpr bool AreAllDumpable(std::index_sequence<Indices...>) {
31 return (kIsDumpable<boost::pfr::tuple_element_t<Indices, T>> && ...);
35constexpr bool IsDumpableAggregate() {
36 if constexpr (std::is_aggregate_v<T> && !meta::kIsDetected<IsNotDumpedAggregate, T>) {
37 constexpr auto kSize = boost::pfr::tuple_size_v<T>;
39 AreAllDumpable<T>(std::make_index_sequence<kSize>{}),
40 "One of the member of an aggregate that was marked as dumpable "
41 "with dump::IsDumpedAggregate is not dumpable. Did you forget "
42 "to include <userver/dump/common.hpp>, "
43 "<userver/dump/common_containers.hpp> or some other header with "
44 "Read and Write functions declarations?"
52template <
typename T, std::size_t... Indices>
53T ReadAggregate(
Reader& reader, std::index_sequence<Indices...>) {
55 return T{reader.Read<boost::pfr::tuple_element_t<Indices, T>>()...};
72 boost::pfr::for_each_field(value, [&writer](
const auto& field) { writer.Write(field); });
87 constexpr auto kSize = boost::pfr::tuple_size_v<T>;
88 return impl::ReadAggregate<T>(reader, std::make_index_sequence<kSize>{});