diff --git a/include/fmt/std.h b/include/fmt/std.h index 4c57b96b..9aafee38 100644 --- a/include/fmt/std.h +++ b/include/fmt/std.h @@ -173,22 +173,6 @@ FMT_END_NAMESPACE #ifdef __cpp_lib_variant FMT_BEGIN_NAMESPACE -FMT_EXPORT -template struct formatter { - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { - return ctx.begin(); - } - - template - auto format(const std::monostate&, FormatContext& ctx) const - -> decltype(ctx.out()) { - auto out = ctx.out(); - out = detail::write(out, "monostate"); - return out; - } -}; - namespace detail { template @@ -222,6 +206,7 @@ auto write_variant_alternative(OutputIt out, const T& v) -> OutputIt { } } // namespace detail + template struct is_variant_like { static constexpr const bool value = detail::is_variant_like_::value; }; @@ -231,6 +216,20 @@ template struct is_variant_formattable { detail::is_variant_formattable_::value; }; +FMT_EXPORT +template struct formatter { + template + FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { + return ctx.begin(); + } + + template + auto format(const std::monostate&, FormatContext& ctx) const + -> decltype(ctx.out()) { + return detail::write(ctx.out(), "monostate"); + } +}; + FMT_EXPORT template struct formatter< @@ -364,11 +363,9 @@ struct formatter< # else out = detail::write_bytes(out, string_view(ti.name()), spec); # endif - out = detail::write(out, Char(':')); - out = detail::write(out, Char(' ')); - out = detail::write_bytes(out, string_view(ex.what()), spec); - - return out; + *out++ = ':'; + *out++ = ' '; + return detail::write_bytes(out, string_view(ex.what()), spec); #endif } };