Skip to content

[time.clock.cast.sys],[time.clock.cast.utc] Use Duration2 for clarity. #4565

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

Merged
merged 2 commits into from
May 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions source/time.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3717,8 +3717,8 @@

\pnum
\mandates
\tcode{SourceClock::to_sys(t)} returns a \tcode{sys_time<Duration>},
where \tcode{Duration} is a valid \tcode{chrono::duration} specialization.
\tcode{SourceClock::to_sys(t)} returns a \tcode{sys_time<Duration2>},
where \tcode{Duration2} is a valid \tcode{chrono::duration} specialization.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a normative change to me. Before, I read this as requiring Duration to be a valid specialization of chrono::duration and requiring SourceClock::to_sys(t) to return sys_time<Duration>. The after condition is obviously quite different, allowing SourceClock::to_sys(t) to return a sys_time parameterized with a completely different specialization of chrono::duration.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I read this as [...] requiring SourceClock::to_sys(t) to return sys_time<Duration>.

That's a plausible reading on its face, but based on my experience implementing this, I think it's too restrictive to be the intended meaning. There's no guarantee that the input Duration will be able to represent the difference between the two clock epochs, so in general there must be some flexibility to return a different duration specialization. That's why all the built-in conversions return a common_type_t<Duration, seconds>. Otherwise, something reasonable like clock_cast<gps_clock>(sys_days{1d / January / 2020y}) won't work if the input and output Duration have to be the same.

But I'm happy to help, if desired, if people prefer to see this escalated to an LWG issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I'm happy to help, if desired, if people prefer to see this escalated to an LWG issue.

We've already gone to the trouble to prepare a PR, I suggest waiting for word from one of the editorial team before dropping this and resubmitting as an LWG issue. My instincts for what the Project Editor will consider to be an editorial change are not infallible.


\pnum
\returns
Expand Down Expand Up @@ -3748,8 +3748,8 @@

\pnum
\mandates
\tcode{DestClock::from_sys(t)} returns a \tcode{time_point<DestClock, Duration>},
where \tcode{Duration} is a valid \tcode{chrono::duration} specialization.
\tcode{DestClock::from_sys(t)} returns a \tcode{time_point<DestClock, Duration2>},
where \tcode{Dura\-tion2} is a valid \tcode{chrono::duration} specialization.

\pnum
\returns
Expand Down Expand Up @@ -3781,8 +3781,8 @@

\pnum
\mandates
\tcode{SourceClock::to_utc(t)} returns a \tcode{utc_time<Duration>},
where \tcode{Duration} is a valid \tcode{chrono::duration} specialization.
\tcode{SourceClock::to_utc(t)} returns a \tcode{utc_time<Duration2>},
where \tcode{Duration2} is a valid \tcode{chrono::duration} specialization.

\pnum
\returns
Expand Down Expand Up @@ -3812,8 +3812,8 @@

\pnum
\mandates
\tcode{DestClock::from_utc(t)} returns a \tcode{time_point<DestClock, Duration>},
where \tcode{Duration} is a valid \tcode{chrono::duration} specialization.
\tcode{DestClock::from_utc(t)} returns a \tcode{time_point<DestClock, Duration2>},
where \tcode{Dura\-tion2} is a valid \tcode{chrono::duration} specialization.

\pnum
\returns
Expand Down