-
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 #1341
<chrono>: [time.duration.io] output #1341
Conversation
If this isn't specified in the standard, I think consistency is more important than being "fancy". Are there any common windows (or linux) command line tools (or logging formats) that use "µs"? If they don't use it, I don't think the standard library needs to innovate here. Anyone knows what libstdc++ or hinnants date library are doing? |
It's implementation-defined https://eel.is/c++draft/time.duration.io#1.5 |
Personally I prefer "µs" because it's more correct. I don't see much value in iostreams being consistent with outputs across encodings but I see value in correctness and disambiguity. |
Because for example you now also have to handle both cases in de-serialization, or search operations/regex expressions. "µs" may be more correct, but I don't see any practical gain/advantage over "us" and virtually any entity that "looks" at the output (be it a human or a program" will have to be able to handle the "us" case anyway. |
Just to be clear though: I don't have a strong opinion on the topic, nor nor lots of experience to backup the opinion. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it's in pretty good shape to me! Thanks for tackling the first of the formatting chrono
things 😸
Mostly nitpicks and an ask for more testing!
tests/std/tests/P0355R7_calendars_and_time_zones_io/duration_output_tests.h
Outdated
Show resolved
Hide resolved
tests/std/tests/P0355R7_calendars_and_time_zones_io/duration_output_tests.h
Outdated
Show resolved
Hide resolved
tests/std/tests/P0355R7_calendars_and_time_zones_io/duration_output_tests.h
Outdated
Show resolved
Hide resolved
Co-authored-by: mnatsuhara <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for implementing this streaming operator! The code and tests look good, I just found some easily fixable issues. I'll validate a fix (double-checking the _ITERATOR_DEBUG_LEVEL
stuff) and will push changes soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI @mnatsuhara, I pushed changes after you approved.
I was able to minimize the clang-format off
region around the _Suffixes
table. clang-format recognizes trailing commas and will place initializers on separate lines. However, clang-format doesn't handle pair{A, B}
CTAD very nicely (it formats the braces as if they're opening a code block), so the macro is now guarded.
FYI @mnatsuhara, I pushed significant changes after you approved. In our internal test suite, the compiler's object file size test failed. This includes most STL headers, does nothing with them, and verifies (with I eventually found a solution. Now, the table is encoded as Although it's a mechanically large change, the actual structure of @MattStephanson's code is essentially unchanged (the callsites just change what they're calling). Because this eliminated the table, there was no reason to retain the Upon reviewing my own code, it occurs to me that this strategy, and the original strategy, doesn't handle character types other than |
That shouldn't be too much trouble to fix, unless you don't want to disturb your current batch merge. I think I can just switch the order of the |
Definitely don't want to disturb it. A followup PR will be great!
I think that would be best. |
Thanks again for implementing this streaming operator - programmers will enjoy it for many gigaseconds. ⌚ |
Partially implements #12, specifically
operator<<(duration)
.I've implemented it with "µs" for the
wchar_t
overload, but I'm not certain that's a good idea. It's clever, but there's value in encoding-independent output as well. Comments welcome.