6#include <boost/describe.hpp>
7#include <boost/system/error_code.hpp>
13 fmt::formatter<std::remove_cvref_t<T>>().format(v, ctx);
17struct fmt::formatter<boost::system::error_code> : fmt::formatter<std::string> {
18 template <
typename Ctx>
19 auto format(
const boost::system::error_code& ec, Ctx& ctx)
const {
20 return formatter<std::string>::format(
21 fmt::format(
"{}: {}", ec.category().name(), ec.message()), ctx);
26struct fmt::formatter<std::error_code> : fmt::formatter<std::string> {
27 template <
typename Ctx>
28 auto format(
const std::error_code& ec, Ctx& ctx)
const {
29 return formatter<std::string>::format(
30 fmt::format(
"{}: {}", ec.category().name(), ec.message()), ctx);
38 boost::describe::has_describe_bases<T>::value &&
39 boost::describe::has_describe_members<T>::value && !std::is_union_v<T>;
41template <formattable_struct T>
42struct fmt::formatter<T, char> {
44 constexpr auto parse(format_parse_context& ctx) {
45 const auto* it = ctx.begin();
46 const auto* end = ctx.end();
48 if (it != end && *it !=
'}') {
49 fmt::throw_format_error(
"invalid format");
56 auto format(T
const& t, format_context& ctx)
const {
58 boost::describe::describe_bases<T, boost::describe::mod_any_access>;
60 boost::describe::describe_members<T, boost::describe::mod_any_access>;
69 boost::mp11::mp_for_each<Bd>([&](
auto d) {
76 out = fmt::format_to(out,
" {}",
77 static_cast<typename decltype(d)::type const&
>(t));
80 boost::mp11::mp_for_each<Md>([&](
auto d) {
87 out = fmt::format_to(out,
" .{}: {}", d.name, t.*d.pointer);
105template <formattable_enum T>
106struct fmt::formatter<T, char> {
108 using U = std::underlying_type_t<T>;
110 fmt::formatter<std::string_view, char> sf_;
111 fmt::formatter<U, char> nf_;
114 constexpr auto parse(fmt::format_parse_context& ctx) {
115 auto i1 = sf_.parse(ctx);
116 auto i2 = nf_.parse(ctx);
119 fmt::throw_format_error(
"invalid format");
125 auto format(T
const& t, fmt::format_context& ctx)
const {
126 char const* s = boost::describe::enum_to_string(t, 0);
129 return sf_.format(s, ctx);
131 return nf_.format(
static_cast<U
>(t), ctx);
constexpr auto GetTypeName() -> std::string
Definition reflect.hpp:15