Created on 2019-11-05.00:00:00 last changed 46 months ago
Proposed resolution:
This wording is relative to N4835.
Modify [time.duration.io] as indicated:
template<class charT, class traits, class Rep, class Period> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const duration<Rep, Period>& d);-2- Effects:
-1- Requires: Rep is an integral type whose integer conversion rank ([conv.rank]) is greater than or equal to that of short, or a floating-point type. charT is char or wchar_t.Forms a basic_string<charT, traits> from d.count() using to_string if charT is char, or to_wstring if charT is wchar_t. Appends the units suffix described below to the basic_string. Inserts the resulting basic_string into os. [Note: This specification ensures that the result of this streaming operation will obey the width and alignment properties of the stream. — end note]Inserts the duration d onto the stream os as if it were implemented as follows:-3-basic_ostringstream<charT, traits> s; s.flags(os.flags()); s.imbue(os.getloc()); s.precision(os.precision()); s << d.count() << units_suffix; return os << s.str();The units suffixunits_suffix depends on the type Period::type as follows:In the list above the use of num and den refer to the static data members of Period::type, which are converted to arrays of charT using a decimal conversion with no leading zeroes. -4- If Period::type is micro, but the character U+00B5 cannot be represented in the encoding used for charT,
(3.1) — If Period::type is atto,
the suffixunits_suffix is "as".(3.2) — Otherwise, if Period::type is femto,
the suffixunits_suffix is "fs".(3.3) — Otherwise, if Period::type is pico,
the suffixunits_suffix is "ps".(3.4) — Otherwise, if Period::type is nano,
the suffixunits_suffix is "ns".(3.5) — Otherwise, if Period::type is micro,
the suffixunits_suffix is "µs" ("\u00b5\u0073").(3.6) — Otherwise, if Period::type is milli,
the suffixunits_suffix is "ms".(3.7) — Otherwise, if Period::type is centi,
the suffixunits_suffix is "cs".(3.8) — Otherwise, if Period::type is deci,
the suffixunits_suffix is "ds".(3.9) — Otherwise, if Period::type is ratio<1>,
the suffixunits_suffix is "s".(3.10) — Otherwise, if Period::type is deca,
the suffixunits_suffix is "das".(3.11) — Otherwise, if Period::type is hecto,
the suffixunits_suffix is "hs".(3.12) — Otherwise, if Period::type is kilo,
the suffixunits_suffix is "ks".(3.13) — Otherwise, if Period::type is mega,
the suffixunits_suffix is "Ms".(3.14) — Otherwise, if Period::type is giga,
the suffixunits_suffix is "Gs".(3.15) — Otherwise, if Period::type is tera,
the suffixunits_suffix is "Ts".(3.16) — Otherwise, if Period::type is peta,
the suffixunits_suffix is "Ps".(3.17) — Otherwise, if Period::type is exa,
the suffixunits_suffix is "Es".(3.18) — Otherwise, if Period::type is ratio<60>,
the suffixunits_suffix is "min".(3.19) — Otherwise, if Period::type is ratio<3600>,
the suffixunits_suffix is "h".(3.20) — Otherwise, if Period::type is ratio<86400>,
the suffixunits_suffix is "d".(3.21) — Otherwise, if Period::type::den == 1,
the suffixunits_suffix is "[num]s".(3.22) — Otherwise,
the suffixunits_suffix is "[num/den]s".the unit suffixunits_suffix "us" is used instead of "µs". -5- Returns: os.
[ 2019-11 Status to Ready during Wednesday morning issue processing in Belfast. ]
Addresses US 334
operator<< for floating-point durations always produces output with six digits after the decimal point, and doesn't use the stream's locale either.
Proposed change:
Rewrite the specification to not rely on to_string() for floating-point formatting.History | |||
---|---|---|---|
Date | User | Action | Args |
2021-02-25 10:48:01 | admin | set | status: wp -> c++20 |
2020-02-24 16:02:59 | admin | set | status: voting -> wp |
2020-01-17 04:54:50 | admin | set | status: ready -> voting |
2019-11-07 08:09:03 | admin | set | messages: + msg10780 |
2019-11-07 08:09:03 | admin | set | status: new -> ready |
2019-11-05 19:46:08 | admin | set | messages: + msg10750 |
2019-11-05 00:00:00 | admin | create |