This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.
<compare>
from most library headersSection: 17.12.2 [coroutine.syn], 19.5.2 [system.error.syn], 22.2.1 [utility.syn], 22.4.2 [tuple.syn], 22.5.2 [optional.syn], 22.6.2 [variant.syn], 20.2.2 [memory.syn], 17.7.6 [type.index.synopsis], 27.4.2 [string.syn], 27.3.2 [string.view.synop], 23.3.2 [array.syn], 23.3.4 [deque.syn], 23.3.6 [forward.list.syn], 23.3.8 [list.syn], 23.3.10 [vector.syn], 23.4.2 [associative.map.syn], 23.4.5 [associative.set.syn], 23.5.2 [unord.map.syn], 23.5.5 [unord.set.syn], 23.6.2 [queue.syn], 23.6.5 [stack.syn], 24.2 [iterator.synopsis], 25.2 [ranges.syn], 30.2 [time.syn], 31.12.4 [fs.filesystem.syn], 28.6.3 [re.syn], 32.4.2 [thread.syn] Status: C++20 Submitter: United States Opened: 2019-11-07 Last modified: 2021-02-25
Priority: 0
View all other issues in [coroutine.syn].
View all issues with C++20 status.
Discussion:
Addresses US 181
The spaceship operator<=>
is typically not usable unless the library
header <compare>
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 #include
-ing <initializer_list>
in C++11,
these headers should mandate a transitive #include <compare>
.
#include <compare>
to the header synopsis for each of the following headers:
<array> <chrono> <coroutine> <deque> <forward_list> <filesystem> <iterator> <list> <map> <memory> <optional> <queue> <ranges> <regex> <set> <stack> <string> <string_view> <system_error> <thread> <tuple> <type_index> <unordered_map> <unordered_set> <utility> <variant> <vector>
[2019-11 Moved to Ready on Friday AM in Belfast]
Proposed resolution:
This wording is relative to N4835.
Add
#include <compare>
to the following header synopses: