<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3383: &sect;[time.zone.leap.nonmembers] sys_seconds should be replaced with seconds</title>
<meta property="og:title" content="Issue 3383: &sect;[time.zone.leap.nonmembers] sys_seconds should be replaced with seconds">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3383.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++20">C++20</a> status.</em></p>
<h3 id="3383"><a href="lwg-defects.html#3383">3383</a>. &sect;[time.zone.leap.nonmembers] <code>sys_seconds</code> should be replaced with <code>seconds</code></h3>
<p><b>Section:</b> 30.11.8.3 <a href="https://wg21.link/time.zone.leap.nonmembers">[time.zone.leap.nonmembers]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Jiang An <b>Opened:</b> 2020-01-30 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>1
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>
<p>
In <a href="https://wg21.link/n4849">N4849</a> 30.11.8.3 <a href="https://wg21.link/time.zone.leap.nonmembers">[time.zone.leap.nonmembers]</a>/12, the type 
template parameter <code>Duration</code> is constrained by <code>three_way_comparable_with&lt;sys_seconds&gt;</code>. 
However, since <code>std::chrono::sys_seconds</code> is a time point type and <code>Duration</code> must be a 
duration type, they can never be compared directly via <code>operator&lt;=&gt;</code>.
<p/>
I guess that the actual intent is comparing <code>Duration</code> with the duration type of 
<code>std::chrono::sys_seconds</code>, i.e. <code>std::chrono::seconds</code>. And thus <code>sys_seconds</code> 
should be replaced with <code>seconds</code> here.
</p>

<p><i>[2020-02 Prioritized as P1 Monday morning in Prague]</i></p>


<strong>Previous resolution [SUPERSEDED]:</strong>
<blockquote class="note">
<p>This wording is relative to <a href="https://wg21.link/n4849">N4849</a>.</p>

<ol>
<li><p>Modify 30.2 <a href="https://wg21.link/time.syn">[time.syn]</a>, header <code>&lt;chrono&gt;</code> synopsis, as indicated:</p>

<blockquote>
<pre>
namespace std {
  [&hellip;]
  namespace chrono {
    [&hellip;]
    template&lt;three_way_comparable_with&lt;<del>sys_</del>seconds&gt; Duration&gt;
      auto operator&lt;=&gt;(const leap&amp; x, const sys_time&lt;Duration&gt;&amp; y);
    [&hellip;]
  }
  [&hellip;]
}
</pre>
<blockquote>
</blockquote>
</blockquote>
</li>

<li><p>Modify 30.11.8.3 <a href="https://wg21.link/time.zone.leap.nonmembers">[time.zone.leap.nonmembers]</a> as indicated:</p>

<blockquote>
<pre>
template&lt;three_way_comparable_with&lt;<del>sys_</del>seconds&gt; Duration&gt;
  constexpr auto operator&lt;=&gt;(const leap&amp; x, const sys_time&lt;Duration&gt;&amp; y) noexcept;
</pre>
<blockquote>
<p>
-12- <i>Returns:</i> <code>x.date() &lt;=&gt; y</code>.
</p>
</blockquote>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2020-02-10, Prague; Howard suggests alternative wording]</i></p>

<p>
The below shown alternative wording does more directly describe the constrained code (by comparing 
<code>time_point</code>s), even though in the very end the code specifying the effects finally goes down 
to actually return <code>x.date().time_since_epoch() &lt;=&gt; y.time_since_epoch()</code> (thus comparing 
<code>duration</code>s).
</p>

<strong>Previous resolution [SUPERSEDED]:</strong>
<blockquote class="note">
<p>This wording is relative to <a href="https://wg21.link/n4849">N4849</a>.</p>

<ol>
<li><p>Modify 30.2 <a href="https://wg21.link/time.syn">[time.syn]</a>, header <code>&lt;chrono&gt;</code> synopsis, as indicated:</p>

<blockquote class="note">
<p>
The synopsis does provide an additional drive-by fix to eliminate the mismatch of the <code>constexpr</code>
and <code>noexcept</code> in declaration and prototype specification.
</p>
</blockquote>

<blockquote>
<pre>
namespace std {
  [&hellip;]
  namespace chrono {
    [&hellip;]
    template&lt;<del>three_way_comparable_with&lt;sys_seconds&gt;</del><ins>class</ins> Duration&gt;
      <ins>requires three_way_comparable_with&lt;sys_seconds, sys_time&lt;Duration&gt;&gt;</ins>
        <ins>constexpr</ins> auto operator&lt;=&gt;(const leap&amp; x, const sys_time&lt;Duration&gt;&amp; y) <ins>noexcept</ins>;
    [&hellip;]
  }
  [&hellip;]
}
</pre>
<blockquote>
</blockquote>
</blockquote>
</li>

<li><p>Modify 30.11.8.3 <a href="https://wg21.link/time.zone.leap.nonmembers">[time.zone.leap.nonmembers]</a> as indicated:</p>

<blockquote>
<pre>
template&lt;<del>three_way_comparable_with&lt;sys_seconds&gt;</del><ins>class</ins> Duration&gt;
  <ins>requires three_way_comparable_with&lt;sys_seconds, sys_time&lt;Duration&gt;&gt;</ins>
    constexpr auto operator&lt;=&gt;(const leap&amp; x, const sys_time&lt;Duration&gt;&amp; y) noexcept;
</pre>
<blockquote>
<p>
-12- <i>Returns:</i> <code>x.date() &lt;=&gt; y</code>.
</p>
</blockquote>
</blockquote>
</li>
</ol>
</blockquote>

<p><i>[2020-02-11, Prague; Daniel suggests alternative wording]</i></p>

<p>
During today's LWG discussion of this issue the observation was made that there also exists a 
mismatch regarding the <code>noexcept</code> specifier for both declarations, but for this second deviation
a corresponding change does <em>not</em> 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 <code>operator&lt;=&gt;</code> or other comparison function declarations of the 
<code>duration</code> and <code>time_point</code> templates are <em>not</em> specified as <code>noexcept</code> 
function templates). The revised wording below does therefore intentionally <em>not</em> change the
currently existing <code>noexcept</code>-specifier mismatch, but a separate issue should instead be
opened for the general <code>noexcept</code>-specifier mismatches for all comparison function templates
of <code>std::chrono::leap</code>. Daniel has volunteered to take care for this issue.
</p>

<p><i>[2020-02 Moved to Immediate on Tuesday in Prague.]</i></p>



<p id="res-3383"><b>Proposed resolution:</b></p>
<p>This wording is relative to <a href="https://wg21.link/n4849">N4849</a>.</p>

<ol>
<li><p>Modify 30.2 <a href="https://wg21.link/time.syn">[time.syn]</a>, header <code>&lt;chrono&gt;</code> synopsis, as indicated:</p>

<blockquote class="note">
<p>
[<i>Drafting note:</i> The synopsis does provide an additional drive-by fix to eliminate the mismatch of the 
<code>constexpr</code> in declaration and prototype specification, but does <em>not</em> so for a similar
mismatch of the exception-specifications of both declarations.]
</p>
</blockquote>

<blockquote>
<pre>
namespace std {
  [&hellip;]
  namespace chrono {
    [&hellip;]
    template&lt;<del>three_way_comparable_with&lt;sys_seconds&gt;</del><ins>class</ins> Duration&gt;
      <ins>requires three_way_comparable_with&lt;sys_seconds, sys_time&lt;Duration&gt;&gt;</ins>
        <ins>constexpr</ins> auto operator&lt;=&gt;(const leap&amp; x, const sys_time&lt;Duration&gt;&amp; y);
    [&hellip;]
  }
  [&hellip;]
}
</pre>
<blockquote>
</blockquote>
</blockquote>
</li>

<li><p>Modify 30.11.8.3 <a href="https://wg21.link/time.zone.leap.nonmembers">[time.zone.leap.nonmembers]</a> as indicated:</p>

<blockquote>
<pre>
template&lt;<del>three_way_comparable_with&lt;sys_seconds&gt;</del><ins>class</ins> Duration&gt;
  <ins>requires three_way_comparable_with&lt;sys_seconds, sys_time&lt;Duration&gt;&gt;</ins>
    constexpr auto operator&lt;=&gt;(const leap&amp; x, const sys_time&lt;Duration&gt;&amp; y) noexcept;
</pre>
<blockquote>
<p>
-12- <i>Returns:</i> <code>x.date() &lt;=&gt; y</code>.
</p>
</blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
