This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.
sys_seconds should be replaced with secondsSection: 30.11.8.3 [time.zone.leap.nonmembers] Status: C++20 Submitter: Jiang An Opened: 2020-01-30 Last modified: 2021-02-25
Priority: 1
View all issues with C++20 status.
Discussion:
In N4849 30.11.8.3 [time.zone.leap.nonmembers]/12, the type
template parameter Duration is constrained by three_way_comparable_with<sys_seconds>.
However, since std::chrono::sys_seconds is a time point type and Duration must be a
duration type, they can never be compared directly via operator<=>.
Duration with the duration type of
std::chrono::sys_seconds, i.e. std::chrono::seconds. And thus sys_seconds
should be replaced with seconds here.
[2020-02 Prioritized as P1 Monday morning in Prague]
Previous resolution [SUPERSEDED]:This wording is relative to N4849.
Modify 30.2 [time.syn], header
<chrono>synopsis, as indicated:namespace std { […] namespace chrono { […] template<three_way_comparable_with<sys_seconds> Duration> auto operator<=>(const leap& x, const sys_time<Duration>& y); […] } […] }Modify 30.11.8.3 [time.zone.leap.nonmembers] as indicated:
template<three_way_comparable_with<sys_seconds> Duration> constexpr auto operator<=>(const leap& x, const sys_time<Duration>& y) noexcept;-12- Returns:
x.date() <=> y.
[2020-02-10, Prague; Howard suggests alternative wording]
The below shown alternative wording does more directly describe the constrained code (by comparing
time_points), even though in the very end the code specifying the effects finally goes down
to actually return x.date().time_since_epoch() <=> y.time_since_epoch() (thus comparing
durations).
This wording is relative to N4849.
Modify 30.2 [time.syn], header
<chrono>synopsis, as indicated:The synopsis does provide an additional drive-by fix to eliminate the mismatch of the
constexprandnoexceptin declaration and prototype specification.namespace std { […] namespace chrono { […] template<three_way_comparable_with<sys_seconds>class Duration> requires three_way_comparable_with<sys_seconds, sys_time<Duration>> constexpr auto operator<=>(const leap& x, const sys_time<Duration>& y) noexcept; […] } […] }Modify 30.11.8.3 [time.zone.leap.nonmembers] as indicated:
template<three_way_comparable_with<sys_seconds>class Duration> requires three_way_comparable_with<sys_seconds, sys_time<Duration>> constexpr auto operator<=>(const leap& x, const sys_time<Duration>& y) noexcept;-12- Returns:
x.date() <=> y.
[2020-02-11, Prague; Daniel suggests alternative wording]
During today's LWG discussion of this issue the observation was made that there also exists a
mismatch regarding the noexcept specifier for both declarations, but for this second deviation
a corresponding change does not seem to be a good drive-by fix candidate, because we have a
function template here that allows supporting user-defined types, whose comparison may throw (Note
that the corresponding operator<=> or other comparison function declarations of the
duration and time_point templates are not specified as noexcept
function templates). The revised wording below does therefore intentionally not change the
currently existing noexcept-specifier mismatch, but a separate issue should instead be
opened for the general noexcept-specifier mismatches for all comparison function templates
of std::chrono::leap. Daniel has volunteered to take care for this issue.
[2020-02 Moved to Immediate on Tuesday in Prague.]
Proposed resolution:
This wording is relative to N4849.
Modify 30.2 [time.syn], header <chrono> synopsis, as indicated:
[Drafting note: The synopsis does provide an additional drive-by fix to eliminate the mismatch of the
constexprin declaration and prototype specification, but does not so for a similar mismatch of the exception-specifications of both declarations.]
namespace std { […] namespace chrono { […] template<three_way_comparable_with<sys_seconds>class Duration> requires three_way_comparable_with<sys_seconds, sys_time<Duration>> constexpr auto operator<=>(const leap& x, const sys_time<Duration>& y); […] } […] }
Modify 30.11.8.3 [time.zone.leap.nonmembers] as indicated:
template<three_way_comparable_with<sys_seconds>class Duration> requires three_way_comparable_with<sys_seconds, sys_time<Duration>> constexpr auto operator<=>(const leap& x, const sys_time<Duration>& y) noexcept;-12- Returns:
x.date() <=> y.