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> &&
37 !meta::kIsDetected<IsNotDumpedAggregate, T>) {
38 constexpr auto kSize = boost::pfr::tuple_size_v<T>;
40 AreAllDumpable<T>(std::make_index_sequence<kSize>{}),
41 "One of the member of an aggregate that was marked as dumpable "
42 "with dump::IsDumpedAggregate is not dumpable. Did you forget "
43 "to include <userver/dump/common.hpp>, "
44 "<userver/dump/common_containers.hpp> or some other header with "
45 "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>>()...};
73 boost::pfr::for_each_field(
74 value, [&writer](
const auto& field) { writer.Write(field); });
90 constexpr auto kSize = boost::pfr::tuple_size_v<T>;
91 return impl::ReadAggregate<T>(reader, std::make_index_sequence<kSize>{});