diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2023-08-15 16:35:22 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2023-08-17 20:24:17 +0100 |
commit | c992acdc6774ef3d566fab5f324d254bed1b9d4b (patch) | |
tree | 8efe75b5a295fd8bc1b1c4b67baf6b49fe1c9898 /gcc | |
parent | 023a62b77f999b002d4c56a94475684a4d209788 (diff) | |
download | gcc-c992acdc6774ef3d566fab5f324d254bed1b9d4b.zip gcc-c992acdc6774ef3d566fab5f324d254bed1b9d4b.tar.gz gcc-c992acdc6774ef3d566fab5f324d254bed1b9d4b.tar.bz2 |
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.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions