Skip to content
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>: Formatting cleanups #1842

Merged

Conversation

StephanTLavavej
Copy link
Member

<chrono>

  • Headers:
    • <chrono>: [time.duration.io] output #1341 included <sstream> unconditionally, but it's needed for C++20 only.
    • We need <iomanip> for put_time() in concepts mode only.
    • We don't need <iostream> (which provides the standard iostream objects cout etc.). Our implementation of <sstream> already drags in <istream> and <ostream>.
  • We don't need to define _Is_hh_mm_ss; we can use _Is_specialization_v.
  • Simplify _Choose_literal(); now that we have if constexpr, we don't need the struct layer.
    • Add _NODISCARD, top-level const, noexcept.
  • When taking an unnamed _Auto_id_tag, there's no need for const.
  • _Chrono_specs_setter::_Specs can be private; we haven't needed derived classes yet.
  • In _Parse_chrono_format_specs(), we always return when _Begin == _End (i.e. at the beginning of the function, and whenever updating _Begin). Therefore, we don't need to check _Begin != _End when verifying that the chrono-specs begin with a conversion-spec.
    • "conversion-spec", singular, is the grammar term.
    • After previous refactorings, _Next_ch no longer has a purpose (and has a slightly confusing name now). We can simply switch on *_Begin.
  • Add _STD qualification to format() calls.
  • Upgrade the modifier table to static constexpr (no functional difference).
  • _Chrono_formatter::_Write just needs a basic_ostringstream, instead of a general basic_stringstream.
  • Undo /* strengthened */ rewrapping that had diverged from main.
  • #undef _STATICALLY_WIDEN at the end of <chrono>, to avoid temptation.

P0355R7_calendars_and_time_zones_formatting/test.cpp

  • This test should include <sstream>.
  • stream_helper() just needs a basic_ostringstream.
  • Mark print() as temporary, as it's unused.

@StephanTLavavej StephanTLavavej added the chrono C++20 chrono label Apr 16, 2021
@StephanTLavavej StephanTLavavej requested a review from a team as a code owner April 16, 2021 02:17
@StephanTLavavej StephanTLavavej merged commit 4c236a3 into microsoft:chronat2 Apr 16, 2021
@StephanTLavavej StephanTLavavej deleted the chronat2_cleanups branch April 16, 2021 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chrono C++20 chrono
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant