9#include <boost/describe/enumerators.hpp>
10#include <boost/mp11/algorithm.hpp>
11#include <boost/pfr.hpp>
12#include <boost/pfr/traits.hpp>
13#include <boost/type_index.hpp>
15#include <fmt/format.h>
16#include <fmt/ranges.h>
17#include <range/v3/algorithm/copy.hpp>
18#include <range/v3/range/concepts.hpp>
29template <
typename Aggregate,
StaticString AggregateName,
auto... Fields>
34 constexpr auto parse(fmt::format_parse_context& ctx) {
39 constexpr auto get_fields(
const Aggregate& from)
const {
return std::tuple{((&from)->*(Fields.second))...}; }
42 return std::tuple{
asmgrader::pair{Fields.first, ((&from)->*(Fields.second))}...};
45 constexpr auto normal_format(
const Aggregate& from, fmt::format_context& ctx)
const {
47 constexpr std::string_view sep =
", ";
51 return fmt::format_to(ctx.out(),
"{}", fmt::join(fields, sep));
54 constexpr auto debug_format(
const Aggregate& from, fmt::format_context& ctx)
const {
58 constexpr std::string_view sep =
", ";
60 constexpr std::string_view leading =
" {";
61 constexpr std::string_view trailing =
"}";
66 auto field_writer = [&,
this, first =
true](
const auto&
pair)
mutable {
68 ranges::copy(sep, ctx_iter);
75 fmt::format_to(ctx_iter,
"{}{}", AggregateName, leading);
77 std::apply([&field_writer](
const auto&... elems) { (field_writer(elems), ...); }, fields);
79 ranges::copy(trailing, ctx_iter);
84 constexpr auto format(
const Aggregate& from, fmt::format_context& ctx)
const {
fmt::appender is non-comformat to the std iterator specification, and thus does not work with the eno...
Definition asm_function.hpp:123
pair(T1, T2) -> pair< T1, T2 >
StaticString(const char(&input)[N]) -> StaticString< N - 1 >
constexpr U2 second
Definition pair.hpp:34
Definition fmt_appender_adaptor.hpp:15