Title
§[time.zone.leap.nonmembers] sys_seconds should be replaced with seconds
Status
c++20
Section
[time.zone.leap.nonmembers]
Submitter
Jiang An

Created on 2020-01-30.00:00:00 last changed 46 months ago

Messages

Date: 2020-02-12.03:28:55

Proposed resolution:

This wording is relative to N4849.

  1. Modify [time.syn], header <chrono> synopsis, as indicated:

    [Drafting note: The synopsis does provide an additional drive-by fix to eliminate the mismatch of the constexpr in 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);
        […]
      }
      […]
    }
    
  2. Modify [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.

Date: 2020-02-12.03:28:55

[ 2020-02 Moved to Immediate on Tuesday in Prague. ]

Date: 2020-02-15.00:00:00

[ 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.

Date: 2020-02-15.00:00:00

[ 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).

Previous resolution [SUPERSEDED]:

This wording is relative to N4849.

  1. Modify [time.syn], header <chrono> synopsis, as indicated:

    The synopsis does provide an additional drive-by fix to eliminate the mismatch of the constexpr and noexcept in 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;
        […]
      }
      […]
    }
    
  2. Modify [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.

Date: 2020-02-10.20:28:06

[ 2020-02 Prioritized as P1 Monday morning in Prague ]

Previous resolution [SUPERSEDED]:

This wording is relative to N4849.

  1. Modify [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);
        […]
      }
      […]
    }
    
  2. Modify [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.

Date: 2020-01-30.00:00:00

In N4849 [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<=>.

I guess that the actual intent is comparing 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.

History
Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2020-02-24 16:02:59adminsetstatus: immediate -> wp
2020-02-12 03:28:55adminsetmessages: + msg11043
2020-02-12 03:28:55adminsetstatus: new -> immediate
2020-02-11 17:23:05adminsetmessages: + msg11039
2020-02-10 20:28:06adminsetmessages: + msg11036
2020-02-10 19:13:13adminsetmessages: + msg11018
2020-02-01 13:41:23adminsetmessages: + msg10978
2020-01-30 00:00:00admincreate