-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<chrono>: [time.duration.io] output should handle types beyond char and wchar_t #1430
Comments
Are they any tricks for using iostreams classes with STL/tests/std/tests/prefix.lst Line 6 in 19c683d
Line 2397 in 19c683d
Lines 1619 to 1635 in 19c683d
|
The iostreams class templates only support characters of type That said, I'm not sure what @StephanTLavavej has in mind for support of other character types. |
@StephanTLavavej, what do you think of this, in light of @CaseyCarter's comments? It looks like the library is not required, and does not attempt, to support iostream classes using other than |
Yep, I agree that this is a non-bug. Thanks for looking into it (and apologies for the delayed response). |
When #1341 implemented
operator<<(basic_ostream&, const duration&)
, its unit suffix logic handled onlychar
andwchar_t
:STL/stl/inc/chrono
Lines 625 to 662 in 6458199
However, WG21-N4868 27.5.11 [time.duration.io]/1 doesn't limit
charT
to being onlychar
andwchar_t
. Instead, it depicts narrow string literals being directly streamed into thebasic_ostream
regardless of itscharT
(which works becauseconst char *
is always streamable, albeit with reduced performance if the types differ).Retaining the
wchar_t
logic is permitted and improves performance, so we just need to fix this for other character types (likechar8_t
,char16_t
, andchar32_t
).@MattStephanson's first suggested strategy in #1341 (comment) sounds good:
We should also add test coverage for this - it doesn't have to be exhaustive, just testing a literal and a general suffix for another character type would be sufficient.
The text was updated successfully, but these errors were encountered: