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],[time.clock.cast.utc] Use Duration2 for clarity. #4565
Conversation
Maybe this needs to be shorter, like |
"Overfull \hbox" is latex telling us there's a long-and-unbreakable word at the end of a line overflowing ~10pts (in these cases) into the margin, and that wrapping it to the next line would leave too much whitespace on the current line. In other words, it can't find a way to flow this text that doesn't look terrible within the constraints it has been given. The fix is for a human to look at the generated output to see what the problem word is, and either introduce a discretionary hyphen with See StephanTLavavej#1. |
\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. |
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 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
.
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.
I read this as [...] requiring
SourceClock::to_sys(t)
to returnsys_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.
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.
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.
The "where ..." phrase seems to imply we're talking about a fresh Duration here, but there is another Duration in scope that makes that a stretch. @jwakely , did you implement this? |
We have not implemented this yet. |
Thanks for bringing this to my attention @jensmaurer. This does look like a defect to me, and the fix looks correct to me. Somehow when translating the original documentation to the proposed wording, I introduced this bug. Here is the original documentation: https://howardhinnant.github.io/date/tz.html#clock_cast Search for: "template
I.e. it was some duration that was intended instead of |
@tkoeppe, @jwakely: Any opposition to fixing this editorially, given that @HowardHinnant said the pull request manifests the intended behavior? |
Editorial meeting 2021-04-30: Given the opinions of the stakeholders, this is considered editorial. |
@jwakely, @CaseyCarter: Please take note that we're making this change editorially. |
Sorry for the late comment, but couldn't this be further simplified? What is a "valid" |
Specifically, I think that both instances of "where Duration2 is a valid chrono::duration specialization" could be changed to "for some Duration2" with no change in meaning. |
No opinion either way here. |
I appreciate the concerns, and I sympathize with them, but given the rather invasive nature (from a "squint the wrong way" standpoint) of this pull request, I'd suggest to merge it as-is and have a separate issue to look for "valid specializations" in all of [time]. (I suspect there are more of these). |
That works for me |
The only other cases are [time.clock.cast.sys] and [time.clock.cast.utc]. This change seems consistent with the language there. I think we could remove "valid" there without changing the meaning. |
Fixes #4564.