<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3728: Can't make neither head nor tail of the description of operator&lt;=&gt;(tuple, tuple)</title>
<meta property="og:title" content="Issue 3728: Can't make neither head nor tail of the description of operator&lt;=&gt;(tuple, tuple)">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3728.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#New">New</a> status.</em></p>
<h3 id="3728"><a href="lwg-active.html#3728">3728</a>. Can't make neither head nor tail of the description of <code>operator&lt;=&gt;(tuple, tuple)</code></h3>
<p><b>Section:</b> 22.4.9 <a href="https://wg21.link/tuple.rel">[tuple.rel]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Corentin Jabot <b>Opened:</b> 2022-06-28 <b>Last modified:</b> 2022-07-08</p>
<p><b>Priority: </b>4
</p>
<p><b>View other</b> <a href="lwg-index-open.html#tuple.rel">active issues</a> in [tuple.rel].</p>
<p><b>View all other</b> <a href="lwg-index.html#tuple.rel">issues</a> in [tuple.rel].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The specification of <code>operator&lt;=&gt;(tuple, tuple)</code> (22.4.9 <a href="https://wg21.link/tuple.rel">[tuple.rel]</a>) is described in 
terms of imaginary tuples (<code>t<sub>tail</sub></code>, <code>u<sub>tail</sub></code>, <code>r<sub>tail</sub></code>) 
which is a bit confusing. Indeed, It is not clear that these imaginary tuples need to respect the order of 
elements of <code>u</code> and <code>t</code>, nor whether the value category of the elements in these imaginary 
tuples can or should be conserved. It is possible to reformulate and simplify that description so that  
no imaginary tuple is involved.
<p/>
The remark is copied from the similar wording of <code>operator==</code>
</p>

<p><i>[2022-07-08; Reflector poll]</i></p>

<p>
Set priority to 4 after reflector poll.
Some votes for NAD and preference for the current wording, adding "in order"
to clarify the order of elements in <code>r<sub>tail</sub></code>.
</p>



<p id="res-3728"><b>Proposed resolution:</b></p>
<p>
This wording is relative to <a href="https://wg21.link/N4910" title=" Working Draft, Standard for Programming Language C++">N4910</a>.
</p>

<ol>
<li><p>Modify 22.4.9 <a href="https://wg21.link/tuple.rel">[tuple.rel]</a> as indicated:</p>

<blockquote>
<pre>
template&lt;class... TTypes, class... UTypes&gt;
  constexpr common_comparison_category_t&lt;<i>synth-three-way-result</i>&lt;TTypes, UTypes&gt;...&gt;
    operator&lt;=&gt;(const tuple&lt;TTypes...&gt;&amp; t, const tuple&lt;UTypes...&gt;&amp; u);
</pre>
<blockquote>
<p>
-4- <i><del>Effects</del><ins>Returns</ins></i>: <ins><code><i>synth-three-way</i>(get&lt;i&gt;(t), get&lt;i&gt;(u))</code> 
for the first <code>i</code> for which the result of that expression does not compare equal to <code>0</code>. If no such <code>i</code> 
exists, <code>strong_ordering::equal</code>.</ins><del>Performs a lexicographical comparison between <code>t</code> and <code>u</code>. 
For any two zero-length tuples <code>t</code> and <code>u</code>, <code>t &lt;=&gt; u</code> returns 
<code>strong_ordering::equal</code>. Otherwise, equivalent to:</del>
</p>
<blockquote><pre>
<del>if (auto c = <i>synth-three-way</i>(get&lt;0&gt;(t), get&lt;0&gt;(u)); c != 0) return c;
return t<sub>tail</sub> &lt;=&gt; u<sub>tail</sub>;</del>
</pre></blockquote>
<p>
<del>where <code>r<sub>tail</sub></code> for some tuple <code>r</code> is a tuple containing all but the first 
element of <code>r</code>.</del>
<p/>
<ins>-?- <i>Remarks</i>: The elementary <code><i>synth-three-way</i>(get&lt;i&gt;(t), get&lt;i&gt;(u))</code> 
expressions are evaluated in order from the zeroth index upwards. No element accesses are performed after 
the first invocation that results in a value that does not compare equal to <code>0</code>.</ins>
<p/>
<del>-5- [<i>Note 1</i>: The above definition does not require <code>t<sub>tail</sub></code> (or <code>u<sub>tail</sub></code>) 
to be constructed. It might not even be possible, as <code>t</code> and <code>u</code> are not required to be copy 
constructible. Also, all comparison operator functions are short circuited; they do not perform element 
accesses beyond what is required to determine the result of the comparison. &mdash; <i>end note</i>]</del>
</p>
</blockquote>
</blockquote>
</li>

</ol>





</body>
</html>
