@@ -1694,27 +1694,28 @@ class get_locale {
16941694 }
16951695};
16961696
1697- template <typename Char, typename OutputIt, typename Rep, typename Period>
1697+ template <typename Char, typename Rep, typename Period>
16981698struct duration_formatter {
1699- locale_ref locale;
1700- OutputIt out;
1701- int precision;
1702- bool localized = false ;
1699+ using iterator = basic_appender<Char>;
1700+ iterator out;
17031701 // rep is unsigned to avoid overflow.
17041702 using rep =
17051703 conditional_t <std::is_integral<Rep>::value && sizeof (Rep) < sizeof (int ),
17061704 unsigned , typename make_unsigned_or_unchanged<Rep>::type>;
17071705 rep val;
1706+ int precision;
1707+ locale_ref locale;
1708+ bool localized = false ;
17081709 using seconds = std::chrono::duration<rep>;
17091710 seconds s;
17101711 using milliseconds = std::chrono::duration<rep, std::milli>;
17111712 bool negative;
17121713
1713- using tm_writer_type = tm_writer<OutputIt , Char>;
1714+ using tm_writer_type = tm_writer<iterator , Char>;
17141715
1715- duration_formatter (locale_ref loc, OutputIt o ,
1716- std::chrono::duration<Rep, Period> d )
1717- : locale(loc), out(o), val(static_cast <rep>(d.count())), negative(false ) {
1716+ duration_formatter (iterator o, std::chrono::duration<Rep, Period> d ,
1717+ locale_ref loc )
1718+ : out(o), val(static_cast <rep>(d.count())), locale(loc ), negative(false ) {
17181719 if (d.count () < 0 ) {
17191720 val = 0 - val;
17201721 negative = true ;
@@ -2172,9 +2173,8 @@ struct formatter<std::chrono::duration<Rep, Period>, Char> {
21722173 out = detail::format_duration_value<Char>(out, d.count (), precision);
21732174 detail::format_duration_unit<Char, Period>(out);
21742175 } else {
2175- using duration_formatter =
2176- detail::duration_formatter<Char, decltype (out), Rep, Period>;
2177- auto f = duration_formatter (ctx.locale (), out, d);
2176+ auto f =
2177+ detail::duration_formatter<Char, Rep, Period>(out, d, ctx.locale ());
21782178 f.precision = precision;
21792179 f.localized = specs_.localized ();
21802180 detail::parse_chrono_format (begin, end, f);
0 commit comments