9#include <boost/describe/enum.hpp>
10#include <boost/describe/enumerators.hpp>
11#include <boost/mp11/algorithm.hpp>
12#include <boost/pfr.hpp>
13#include <boost/type_index.hpp>
15#include <fmt/format.h>
16#include <range/v3/algorithm/copy.hpp>
17#include <range/v3/algorithm/find_if.hpp>
18#include <range/v3/range/concepts.hpp>
29template <
typename Enum,
StaticString EnumName,
auto... Enumerators>
34 constexpr auto parse(fmt::format_parse_context& ctx) {
41 std::optional<::asmgrader::pair<std::string_view, Enum>> res;
42 ((Enumerators.second == from ? res = Enumerators : res), ...);
49 constexpr auto normal_format(
const Enum& from, fmt::format_context& ctx)
const {
52 if (val.has_value()) {
53 return fmt::format_to(ctx.out(),
"{}", val->first);
56 return fmt::format_to(ctx.out(),
"<unknown ({})>", fmt::underlying(from));
59 constexpr auto debug_format(
const Enum& from, fmt::format_context& ctx)
const {
62 fmt::format_to(ctx_iter,
"{}{{", EnumName);
66 ranges::copy(
"}", ctx_iter);
71 constexpr auto format(
const Enum& 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
StaticString(const char(&input)[N]) -> StaticString< N - 1 >
Definition fmt_appender_adaptor.hpp:15