Skip to content

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

Description

@StephanTLavavej

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions