This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.

3330. Include <compare> from most library headers

Section: 17.12.1 [coroutine.syn], 19.5.1 [system.error.syn], 20.2.1 [utility.syn], 20.5.2 [tuple.syn], 20.6.2 [optional.syn], 20.7.2 [variant.syn], 20.10.2 [memory.syn], 20.17.1 [type.index.synopsis], 21.3.1 [string.syn], 21.4.1 [string.view.synop], 22.3.2 [array.syn], 22.3.3 [deque.syn], 22.3.4 [forward.list.syn], 22.3.5 [list.syn], 22.3.6 [vector.syn], 22.4.2 [associative.map.syn], 22.4.3 [associative.set.syn], 22.5.2 [unord.map.syn], 22.5.3 [unord.set.syn], 22.6.2 [queue.syn], 22.6.3 [stack.syn], 23.2 [iterator.synopsis], 24.2 [ranges.syn], 27.2 [time.syn], 29.11.5 [fs.filesystem.syn], 30.4 [re.syn], 32.4.1 [thread.syn] Status: WP Submitter: United States Opened: 2019-11-07 Last modified: 2020-02-24

Priority: 0

View all issues with WP 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>.

Proposed change:

Add:

#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.

  1. Add

    #include <compare>
    

    to the following header synopses:

    1. 17.12.1 [coroutine.syn]
    2. 19.5.1 [system.error.syn]
    3. 20.2.1 [utility.syn]
    4. 20.5.2 [tuple.syn]
    5. 20.6.2 [optional.syn]
    6. 20.7.2 [variant.syn]
    7. 20.10.2 [memory.syn]
    8. 20.17.1 [type.index.synopsis]
    9. 21.3.1 [string.syn]
    10. 21.4.1 [string.view.synop]
    11. 22.3.2 [array.syn]
    12. 22.3.3 [deque.syn]
    13. 22.3.4 [forward.list.syn]
    14. 22.3.5 [list.syn]
    15. 22.3.6 [vector.syn]
    16. 22.4.2 [associative.map.syn]
    17. 22.4.3 [associative.set.syn]
    18. 22.5.2 [unord.map.syn]
    19. 22.5.3 [unord.set.syn]
    20. 22.6.2 [queue.syn]
    21. 22.6.3 [stack.syn]
    22. 23.2 [iterator.synopsis]
    23. 24.2 [ranges.syn]
    24. 27.2 [time.syn]
    25. 29.11.5 [fs.filesystem.syn]
    26. 30.4 [re.syn]
    27. 32.4.1 [thread.syn]