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

[time.clock.cast.sys] and [time.clock.cast.utc] reuse "Duration" confusingly #4564

Closed
StephanTLavavej opened this issue Mar 27, 2021 · 0 comments · Fixed by #4565
Closed

Comments

@StephanTLavavej
Copy link
Contributor

N4885 [time.clock.cast.utc]/2:

template<class Duration>
  auto operator()(const time_point<SourceClock, Duration>& t) const
    -> decltype(SourceClock::to_utc(t));

Mandates: SourceClock::to_utc(t) returns a utc_time<Duration>, where Duration is a valid chrono::duration specialization.

Confusingly, the Duration that this operator() is templated on, is not the same as the Duration in the return type! What this means to say is:

Mandates: SourceClock::to_utc(t) returns a utc_time<Duration2>, where Duration2 is a valid chrono::duration specialization.

Attempting to static_assert that this operator() returns utc_time<Duration> matching the template parameter exactly, will fail to compile (observe that [time.clock.tai.overview] specifies that tai_clock::to_utc() returns utc_time<common_type_t<Duration, seconds>>). Which just happened to me, hence the issue. While I was confused by the wording, the intent seems clear upon a re-read, and I believe that this is an editorial issue, not an LWG issue. Thanks to @MattStephanson for diagnosing this and explaining it to me.

This occurs 4 times:

  • [time.clock.cast.sys]/2
  • [time.clock.cast.sys]/5
  • [time.clock.cast.utc]/2
  • [time.clock.cast.utc]/5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant