<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3331: Define totally_ordered/_with in terms of partially-ordered-with</title>
<meta property="og:title" content="Issue 3331: Define totally_ordered/_with in terms of partially-ordered-with">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3331.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="3331"><a href="lwg-defects.html#3331">3331</a>. Define <code>totally_ordered/_with</code> in terms of <code><i>partially-ordered-with</i></code></h3>
<p><b>Section:</b> 18.5.5 <a href="https://wg21.link/concept.totallyordered">[concept.totallyordered]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Great Britain <b>Opened:</b> 2019-11-08 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>0
</p>
<p><b>View all other</b> <a href="lwg-index.html#concept.totallyordered">issues</a> in [concept.totallyordered].</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><b>Addresses <a href="https://github.com/cplusplus/nbballot/issues/200">GB 202</a></b></p>

<p>
Define <code>totally_ordered[_with]</code>
in terms of <code><i>partially-ordered-with</i></code>.
This will simplify the definition of both concepts
(particularly <code>totally_ordered_with</code>), and
make them in-line with <code>equality_comparable[_with]</code>.
Now that we've defined <code><i>partially-ordered-with</i></code>
for 17.12.4 <a href="https://wg21.link/cmp.concept">[cmp.concept]</a>, we should consider
utilising it in as many locations as possible.
</p><p>
Proposed change:
</p><p>
<pre>
template&lt;class T&gt;
  concept totally_ordered =
    equality_comparable&lt;T&gt; &amp;&amp;
    <i>partially-ordered-with</i>&lt;T, T&gt;;

template&lt;class T, class U&gt;
  concept totally_ordered_with =
    totally_ordered&lt;T&gt; &amp;&amp;
    totally_ordered&lt;U&gt; &amp;&amp;
    common_reference_with&lt;
      const remove_reference_t&lt;T&gt;&amp;,
      const remove_reference_t&lt;U&gt;&amp;&gt; &amp;&amp;
    totally_ordered&lt;
      common_reference_t&lt;
        const remove_reference_t&lt;T&gt;&amp;,
        const remove_reference_t&lt;U&gt;&amp;&gt;&gt; &amp;&amp;
    equality_comparable_with&lt;T, U&gt; &amp;&amp;
    <i>partially-ordered-with</i>&lt;T, U&gt;;
</pre>
</p><p>
LWG discussion in Belfast notes that <a href="lwg-defects.html#3329" title="totally_ordered_with both directly and indirectly requires common_reference_with (Status: C++20)">3329</a><sup><a href="https://cplusplus.github.io/LWG/issue3329" title="Latest snapshot">(i)</a></sup>
also touches the definition of <code>totally_ordered_with</code>;
the two sets of changes are consistent.
</p>
<p><i>[2019-11 Status to Ready Friday afternoon LWG in Belfast]</i></p>



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

<ol>
<li><p>Change 18.5.5 <a href="https://wg21.link/concept.totallyordered">[concept.totallyordered]</a> as follows:</p>
<blockquote><pre>
template&lt;class T&gt;
  concept totally_ordered =
    equality_comparable&lt;T&gt; &amp;&amp; <ins><i>partially-ordered-with</i>&lt;T, T&gt;;</ins>
    <del>requires(const remove_reference_t&lt;T&gt;&amp; a,</del>
             <del>const remove_reference_t&lt;T&gt;&amp; b) {</del>
      <del>{ a &lt;  b } -&gt; boolean;</del>
      <del>{ a &gt;  b } -&gt; boolean;</del>
      <del>{ a &lt;= b } -&gt; boolean;</del>
      <del>{ a &gt;= b } -&gt; boolean;</del>
    <del>};</del>
</pre><p>
-1- For some type <code>T</code>, let <code>a</code>, <code>b</code>, and <code>c</code>
be lvalues of type <code>const remove_reference_t&lt;T&gt;</code>.
<code>T</code> models <code>totally_ordered</code> only if
</p><p>
(1.1) &mdash; Exactly one of <code>bool(a &lt; b)</code>, <code>bool(a &gt; b)</code>,
or <code>bool(a == b)</code> is <code>true</code>.
</p><p>
(1.2) &mdash; If <code>bool(a &lt; b)</code> and <code>bool(b &lt; c)</code>,
then <code>bool(a &lt; c)</code>.
</p><p>
<del>(1.3) &mdash; <code>bool(a &gt; b) == bool(b &lt; a)</code>.</del>
</p><p>
(1.4) &mdash; <code>bool(a &lt;= b) == !bool(b &lt; a)</code>.
</p><p>
(1.5) &mdash; <code>bool(a &gt;= b) == !bool(a &lt; b)</code>.
</p><pre>
template&lt;class T, class U&gt;
  concept totally_ordered_with =
    totally_ordered&lt;T&gt; &amp;&amp; totally_ordered&lt;U&gt; &amp;&amp;
    common_reference_with&lt;const remove_reference_t&lt;T&gt;&amp;, const remove_reference_t&lt;U&gt;&amp;&gt; &amp;&amp;
    totally_ordered&lt;
      common_reference_t&lt;
        const remove_reference_t&lt;T&gt;&amp;,
        const remove_reference_t&lt;U&gt;&amp;&gt;&gt; &amp;&amp;
      equality_comparable_with&lt;T, U&gt; &amp;&amp;
      <ins><i>partially-ordered-with</i>&lt;T, U&gt;;</ins>
      <del>requires(const remove_reference_t&lt;T&gt;&amp; t,</del>
               <del>const remove_reference_t&lt;U&gt;&amp; u) {</del>
        <del>{ t &lt;  u } -&gt; boolean;</del>
        <del>{ t &gt;  u } -&gt; boolean;</del>
        <del>{ t &lt;= u } -&gt; boolean;</del>
        <del>{ t &gt;= u } -&gt; boolean;</del>
        <del>{ u &lt;  t } -&gt; boolean;</del>
        <del>{ u &gt;  t } -&gt; boolean;</del>
        <del>{ u &lt;= t } -&gt; boolean;</del>
        <del>{ u &gt;= t } -&gt; boolean;</del>
      <del>};</del>
</pre><p>
[&hellip;]
</p>
</blockquote>
</li>
</ol>




</body>
</html>
