I got the order of arguments to std::format_to wrong. It was in a
discarded statement, for a case which wasn't being tested.
libstdc++-v3/ChangeLog:
* include/bits/chrono_io.h (__formatter_chrono::_M_S): Fix order
of arguments to std::format_to.
* testsuite/20_util/duration/io.cc: Test subsecond duration with
floating-point rep.
using rep = typename decltype(__ss)::rep;
if constexpr (is_floating_point_v<rep>)
{
- __out = std::format_to(__loc, std::move(__out),
+ __out = std::format_to(std::move(__out), __loc,
_GLIBCXX_WIDEN("{:.{}Lg}"),
__ss.count(),
__hms.fractional_width);
"required by the chrono-specs") != s.npos);
}
}
+
+ std::chrono::duration<float, std::milli> d{0.5};
+ s = std::format("{}", d);
+ VERIFY( s == "0.5ms" );
}
void