<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3330: Include &lt;compare&gt; from most library headers</title>
<meta property="og:title" content="Issue 3330: Include &lt;compare&gt; from most library headers">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3330.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="3330"><a href="lwg-defects.html#3330">3330</a>. Include <code>&lt;compare&gt;</code> from most library headers</h3>
<p><b>Section:</b> 17.13.2 <a href="https://wg21.link/coroutine.syn">[coroutine.syn]</a>, 19.5.2 <a href="https://wg21.link/system.error.syn">[system.error.syn]</a>, 22.2.1 <a href="https://wg21.link/utility.syn">[utility.syn]</a>, 22.4.2 <a href="https://wg21.link/tuple.syn">[tuple.syn]</a>, 22.5.2 <a href="https://wg21.link/optional.syn">[optional.syn]</a>, 22.6.2 <a href="https://wg21.link/variant.syn">[variant.syn]</a>, 20.2.2 <a href="https://wg21.link/memory.syn">[memory.syn]</a>, 17.7.6 <a href="https://wg21.link/type.index.synopsis">[type.index.synopsis]</a>, 27.4.2 <a href="https://wg21.link/string.syn">[string.syn]</a>, 27.3.2 <a href="https://wg21.link/string.view.synop">[string.view.synop]</a>, 23.3.2 <a href="https://wg21.link/array.syn">[array.syn]</a>, 23.3.4 <a href="https://wg21.link/deque.syn">[deque.syn]</a>, 23.3.6 <a href="https://wg21.link/forward.list.syn">[forward.list.syn]</a>, 23.3.10 <a href="https://wg21.link/list.syn">[list.syn]</a>, 23.3.12 <a href="https://wg21.link/vector.syn">[vector.syn]</a>, 23.4.2 <a href="https://wg21.link/associative.map.syn">[associative.map.syn]</a>, 23.4.5 <a href="https://wg21.link/associative.set.syn">[associative.set.syn]</a>, 23.5.2 <a href="https://wg21.link/unord.map.syn">[unord.map.syn]</a>, 23.5.5 <a href="https://wg21.link/unord.set.syn">[unord.set.syn]</a>, 23.6.2 <a href="https://wg21.link/queue.syn">[queue.syn]</a>, 23.6.5 <a href="https://wg21.link/stack.syn">[stack.syn]</a>, 24.2 <a href="https://wg21.link/iterator.synopsis">[iterator.synopsis]</a>, 25.2 <a href="https://wg21.link/ranges.syn">[ranges.syn]</a>, 30.2 <a href="https://wg21.link/time.syn">[time.syn]</a>, 31.12.4 <a href="https://wg21.link/fs.filesystem.syn">[fs.filesystem.syn]</a>, 28.6.3 <a href="https://wg21.link/re.syn">[re.syn]</a>, 32.4.2 <a href="https://wg21.link/thread.syn">[thread.syn]</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#coroutine.syn">issues</a> in [coroutine.syn].</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/179">US 181</a></b></p>

<p>
The spaceship <code>operator&lt;=&gt;</code> is typically not usable unless the library 
header <code>&lt;compare&gt;</code> is directly included by the user. Many standard
library headers provide overloads for this operator. Worse, several standard classes
have replaced their existing definition for comparison operators with a reliance on the
spaceship operator, and existing code will break if the necessary header is not
(transitively) included. In a manner similar to the mandated library headers
transitively <code>#include</code>-ing <code>&lt;initializer_list&gt;</code> in C++11, 
these headers should mandate a transitive <code>#include &lt;compare&gt;</code>.
<p/>
Proposed change:
<p/>
Add:
<p/>
<code>#include &lt;compare&gt;</code>
<p/>
to the header synopsis for each of the following headers:
</p>
<blockquote>
<pre>
&lt;array&gt;
&lt;chrono&gt;
&lt;coroutine&gt;
&lt;deque&gt;
&lt;forward_list&gt;
&lt;filesystem&gt;
&lt;iterator&gt;
&lt;list&gt;
&lt;map&gt;
&lt;memory&gt;
&lt;optional&gt;
&lt;queue&gt;
&lt;ranges&gt;
&lt;regex&gt;
&lt;set&gt;
&lt;stack&gt;
&lt;string&gt;
&lt;string_view&gt;
&lt;system_error&gt;
&lt;thread&gt;
&lt;tuple&gt;
&lt;type_index&gt;
&lt;unordered_map&gt;
&lt;unordered_set&gt;
&lt;utility&gt;
&lt;variant&gt;
&lt;vector&gt;
</pre>
</blockquote>

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



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

<ol>
<li><p>Add</p>
<blockquote><pre>
#include &lt;compare&gt;
</pre></blockquote>
<p>
to the following header synopses:
</p>
<ol>
<li>17.13.2 <a href="https://wg21.link/coroutine.syn">[coroutine.syn]</a></li>
<li>19.5.2 <a href="https://wg21.link/system.error.syn">[system.error.syn]</a></li>
<li>22.2.1 <a href="https://wg21.link/utility.syn">[utility.syn]</a></li>
<li>22.4.2 <a href="https://wg21.link/tuple.syn">[tuple.syn]</a></li>
<li>22.5.2 <a href="https://wg21.link/optional.syn">[optional.syn]</a></li>
<li>22.6.2 <a href="https://wg21.link/variant.syn">[variant.syn]</a></li>
<li>20.2.2 <a href="https://wg21.link/memory.syn">[memory.syn]</a></li>
<li>17.7.6 <a href="https://wg21.link/type.index.synopsis">[type.index.synopsis]</a></li>
<li>27.4.2 <a href="https://wg21.link/string.syn">[string.syn]</a></li>
<li>27.3.2 <a href="https://wg21.link/string.view.synop">[string.view.synop]</a></li>
<li>23.3.2 <a href="https://wg21.link/array.syn">[array.syn]</a></li>
<li>23.3.4 <a href="https://wg21.link/deque.syn">[deque.syn]</a></li>
<li>23.3.6 <a href="https://wg21.link/forward.list.syn">[forward.list.syn]</a></li>
<li>23.3.10 <a href="https://wg21.link/list.syn">[list.syn]</a></li>
<li>23.3.12 <a href="https://wg21.link/vector.syn">[vector.syn]</a></li>
<li>23.4.2 <a href="https://wg21.link/associative.map.syn">[associative.map.syn]</a></li>
<li>23.4.5 <a href="https://wg21.link/associative.set.syn">[associative.set.syn]</a></li>
<li>23.5.2 <a href="https://wg21.link/unord.map.syn">[unord.map.syn]</a></li>
<li>23.5.5 <a href="https://wg21.link/unord.set.syn">[unord.set.syn]</a></li>
<li>23.6.2 <a href="https://wg21.link/queue.syn">[queue.syn]</a></li>
<li>23.6.5 <a href="https://wg21.link/stack.syn">[stack.syn]</a></li>
<li>24.2 <a href="https://wg21.link/iterator.synopsis">[iterator.synopsis]</a></li>
<li>25.2 <a href="https://wg21.link/ranges.syn">[ranges.syn]</a></li>
<li>30.2 <a href="https://wg21.link/time.syn">[time.syn]</a></li>
<li>31.12.4 <a href="https://wg21.link/fs.filesystem.syn">[fs.filesystem.syn]</a></li>
<li>28.6.3 <a href="https://wg21.link/re.syn">[re.syn]</a></li>
<li>32.4.2 <a href="https://wg21.link/thread.syn">[thread.syn]</a></li>
</ol>
</li>
</ol>




</body>
</html>
