forked from fmtlib/fmt
Cleanup std formatters
This commit is contained in:
@ -173,22 +173,6 @@ FMT_END_NAMESPACE
|
|||||||
|
|
||||||
#ifdef __cpp_lib_variant
|
#ifdef __cpp_lib_variant
|
||||||
FMT_BEGIN_NAMESPACE
|
FMT_BEGIN_NAMESPACE
|
||||||
FMT_EXPORT
|
|
||||||
template <typename Char> struct formatter<std::monostate, Char> {
|
|
||||||
template <typename ParseContext>
|
|
||||||
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
|
||||||
return ctx.begin();
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename FormatContext>
|
|
||||||
auto format(const std::monostate&, FormatContext& ctx) const
|
|
||||||
-> decltype(ctx.out()) {
|
|
||||||
auto out = ctx.out();
|
|
||||||
out = detail::write<Char>(out, "monostate");
|
|
||||||
return out;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -222,6 +206,7 @@ auto write_variant_alternative(OutputIt out, const T& v) -> OutputIt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template <typename T> struct is_variant_like {
|
template <typename T> struct is_variant_like {
|
||||||
static constexpr const bool value = detail::is_variant_like_<T>::value;
|
static constexpr const bool value = detail::is_variant_like_<T>::value;
|
||||||
};
|
};
|
||||||
@ -231,6 +216,20 @@ template <typename T, typename C> struct is_variant_formattable {
|
|||||||
detail::is_variant_formattable_<T, C>::value;
|
detail::is_variant_formattable_<T, C>::value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FMT_EXPORT
|
||||||
|
template <typename Char> struct formatter<std::monostate, Char> {
|
||||||
|
template <typename ParseContext>
|
||||||
|
FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
|
||||||
|
return ctx.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename FormatContext>
|
||||||
|
auto format(const std::monostate&, FormatContext& ctx) const
|
||||||
|
-> decltype(ctx.out()) {
|
||||||
|
return detail::write<Char>(ctx.out(), "monostate");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
FMT_EXPORT
|
FMT_EXPORT
|
||||||
template <typename Variant, typename Char>
|
template <typename Variant, typename Char>
|
||||||
struct formatter<
|
struct formatter<
|
||||||
@ -364,11 +363,9 @@ struct formatter<
|
|||||||
# else
|
# else
|
||||||
out = detail::write_bytes(out, string_view(ti.name()), spec);
|
out = detail::write_bytes(out, string_view(ti.name()), spec);
|
||||||
# endif
|
# endif
|
||||||
out = detail::write<Char>(out, Char(':'));
|
*out++ = ':';
|
||||||
out = detail::write<Char>(out, Char(' '));
|
*out++ = ' ';
|
||||||
out = detail::write_bytes(out, string_view(ex.what()), spec);
|
return detail::write_bytes(out, string_view(ex.what()), spec);
|
||||||
|
|
||||||
return out;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user