-
- Downloads
libstdc++: Simplify chrono::__units_suffix using std::format
For std::chrono formatting we can simplify __units_suffix by using std::format_to to generate the "[n/m]s" suffix with the correct character type and write directly to the output iterator, so it doesn't need to be widened using ctype. We can't remove the use of ctype::widen for formatting a time zone abbreviation as a wide string, because that can contain arbitrary characters that can't be widened by __to_wstring_numeric. This also fixes a bug in the chrono formatter for %Z which created a dangling wstring_view. libstdc++-v3/ChangeLog: * include/bits/chrono_io.h (__units_suffix_misc): Remove. (__units_suffix): Return a known suffix as string view, do not write unknown suffixes to a buffer. (__fmt_units_suffix): New function that formats the suffix using std::format_to. (operator<<, __chrono_formatter::_M_q): Use __fmt_units_suffix. (__chrono_formatter::_M_Z): Correct lifetime of wstring.
Loading
Please register or sign in to comment