<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3329: totally_ordered_with both directly and indirectly requires common_reference_with</title>
<meta property="og:title" content="Issue 3329: totally_ordered_with both directly and indirectly requires common_reference_with">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3329.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="3329"><a href="lwg-defects.html#3329">3329</a>. <code>totally_ordered_with</code> both directly and indirectly requires <code>common_reference_with</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> United States <b>Opened:</b> 2019-11-07 <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/199">US 201</a></b></p>

<p>
The <code>totally_ordered_with&lt;T, U&gt;</code> redundantly requires both
<code>common_reference_with&lt;const remove_reference_t&amp;, const
remove_reference_t&amp;&gt;</code> and <code>equality_comparable_with&lt;T,
U&gt;</code> (which also has the <code>common_reference_with</code> requirement). The
redundant requirement should be removed.
<p/>
Proposed change:
<p/>
Change the definition of <code>totally_ordered_with</code> to:
</p>
<blockquote>
<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;
    equality_comparable_with&lt;T, U&gt; &amp;&amp;
    totally_ordered&lt;
      common_reference_t&lt;
        const remove_reference_t&lt;T&gt;&amp;,
        const remove_reference_t&lt;U&lt;&amp;&gt;&gt; &amp;&amp;
    requires(const remove_reference_t&lt;T&lt;&amp; t,
                    const remove_reference_t&gt;U&gt;&amp; u) {
      [&hellip; as before &hellip;]
</pre>
</blockquote>

<p><i>[2019-11 Moved to Ready on Friday AM in Belfast]</i></p>



<p id="res-3329"><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 indicated:</p>

<blockquote>
<p>
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>
<ol style="list-style-type: none">
  <li><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></li>
  <li><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></li>
  <li><p>(1.3) &mdash; <code>bool(a &gt; b) == bool(b &lt; a)</code>.</p></li>
  <li><p>(1.4) &mdash; <code>bool(a &lt;= b) == !bool(b &lt; a)</code>.</p></li>
  <li><p>(1.5) &mdash; <code>bool(a &gt;= b) == !bool(a &lt; b)</code>.</p></li>
</ol>
<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;
    <del>common_reference_with&lt;const remove_reference_t&lt;T&gt;&amp;, const remove_reference_t&lt;U&gt;&amp;&gt; &amp;&amp;</del>
    <ins>equality_comparable_with&lt;T, U&gt; &amp;&amp;</ins>
    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;
    <del>equality_comparable_with&lt;T, U&gt; &amp;&amp;</del>
    requires(const remove_reference_t&lt;T&gt;&amp; t,
             const remove_reference_t&lt;U&gt;&amp; u) {
      { t &lt;  u } -&gt; boolean;
      { t &gt;  u } -&gt; boolean;
      { t &lt;= u } -&gt; boolean;
      { t &gt;= u } -&gt; boolean;
      { u &lt;  t } -&gt; boolean;
      { u &gt;  t } -&gt; boolean;
      { u &lt;= t } -&gt; boolean;
      { u &gt;= t } -&gt; boolean;
    };
</pre>
</blockquote>
</li>
</ol>




</body>
</html>
