From c9b14e9bd4964667828e39b263581628a5064e6b Mon Sep 17 00:00:00 2001 From: rbrugo Date: Mon, 7 Mar 2022 16:12:15 +0100 Subject: [PATCH] Inherit from formatter to get the underlying `parse` and `format` --- include/fmt/color.h | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/include/fmt/color.h b/include/fmt/color.h index 179c6f64..c9c5a93c 100644 --- a/include/fmt/color.h +++ b/include/fmt/color.h @@ -643,22 +643,7 @@ template struct styled_arg { FMT_END_DETAIL_NAMESPACE template -struct formatter, Char> { - private: - using value_type = Arg; - using formatter_type = - conditional_t::value, - formatter, Char>, - detail::fallback_formatter>; - - formatter_type value_formatter_; - - public: - template - FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { - return value_formatter_.parse(ctx); - } - +struct formatter, Char> : formatter { template auto format(detail::styled_arg const& arg, FormatContext& ctx) const -> decltype(ctx.out()) { @@ -687,7 +672,7 @@ struct formatter, Char> { detail::make_background_color(ts.get_background()); buf.append(background.begin(), background.end()); } - out = value_formatter_.format(value, ctx); + out = formatter::format(value, ctx); if (has_style) detail::reset_color(buf); return out; }