From 6ee933482dce495e10392e3fb08c0fa80c5c6bd5 Mon Sep 17 00:00:00 2001 From: Vladislav Shchapov Date: Sat, 13 Nov 2021 02:04:02 +0500 Subject: [PATCH] Simplify std::tm formatter --- include/fmt/chrono.h | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index be28cdee6296a..6e1fba4f1ffbb 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -1848,18 +1848,6 @@ template struct formatter { return end; } - template - It do_format(It out, const std::tm& tm, const std::locale& loc) const { - auto w = detail::tm_writer(loc, out, tm); - if (spec_ == spec::year_month_day) - w.on_iso_date(); - else if (spec_ == spec::hh_mm_ss) - w.on_iso_time(); - else - detail::parse_chrono_format(specs.begin(), specs.end(), w); - return w.out(); - } - public: template FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) { @@ -1870,8 +1858,15 @@ template struct formatter { auto format(const std::tm& tm, FormatContext& ctx) const -> decltype(ctx.out()) { const auto loc_ref = ctx.locale(); - return this->do_format( - ctx.out(), tm, detail::get_locale{static_cast(loc_ref), loc_ref}); + detail::get_locale loc{static_cast(loc_ref), loc_ref}; + auto w = detail::tm_writer(loc, ctx.out(), tm); + if (spec_ == spec::year_month_day) + w.on_iso_date(); + else if (spec_ == spec::hh_mm_ss) + w.on_iso_time(); + else + detail::parse_chrono_format(specs.begin(), specs.end(), w); + return w.out(); } };