20#include <fmt/format.h>
23struct fmt::formatter<std::any> {
24 template <
typename ParseContext>
25 constexpr auto parse(ParseContext& ctx) ->
decltype(ctx.begin()) {
30 template <
typename FormatContext>
31 auto format(
const std::any& value, FormatContext& ctx) ->
decltype(ctx.out()) {
33 if (
const auto* x = std::any_cast<const char>(&value))
return fmt::format_to(ctx.out(),
"{}", *x);
34 else if (
const auto* x = std::any_cast<const int>(&value))
return fmt::format_to(ctx.out(),
"{}", *x);
35 else if (
const auto* x = std::any_cast<const unsigned>(&value))
return fmt::format_to(ctx.out(),
"{}", *x);
36 else if (
const auto* x = std::any_cast<const size_t>(&value))
return fmt::format_to(ctx.out(),
"{}", *x);
37 else if (
const auto* x = std::any_cast<const std::string>(&value))
return fmt::format_to(ctx.out(),
"{}", *x);
38 else if (
const auto* x = std::any_cast<const double>(&value))
return fmt::format_to(ctx.out(),
"{}", *x);
40 assert(
false &&
"Unknown type in std::any fmt!");
41 return fmt::format_to(ctx.out(),
"<unknown type>");