This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
thread::id spaceship may be inconsistent with equalitySection: 32.4.3.2 [thread.thread.id] Status: New Submitter: Casey Carter Opened: 2021-01-26 Last modified: 2021-03-12
Priority: 3
View all other issues in [thread.thread.id].
View all issues with New status.
Discussion:
32.4.3.2 [thread.thread.id]/5-7 specify the behavior of == and <=> for
std::thread::id:
bool operator==(thread::id x, thread::id y) noexcept;-5- Returns:
trueonly ifxandyrepresent the same thread of execution or neitherxnoryrepresents a thread of execution.strong_ordering operator<=>(thread::id x, thread::id y) noexcept;-6- Let
-7- Returns:P(x, y)be an unspecified total ordering overthread::idas described in 25.8.strong_ordering::lessifP(x, y)istrue. Otherwise,strong_ordering::greaterifP(y, x)istrue. Otherwise,strong_ordering::equal.
"Unspecified total ordering" provides too much freedom, since it does not require that !P(x, y)
holds when x and y both represent the same thread of execution or both represent no
thread of execution. A conforming implementation could return strong_ordering::equal from
<=> for a pair of thread::id values for which == returns false.
We should guarantee consistency of == and <=> for thread::id to
preserve sanity of the programming model.
[2021-03-12; Reflector poll]
Set priority to 3 following reflector poll.
Proposed resolution:
This wording is relative to N4878.
Modify 32.4.3.2 [thread.thread.id] as indicated:
strong_ordering operator<=>(thread::id x, thread::id y) noexcept;-6- Let
-7- Returns:P(x, y)bean unspecifieda total ordering overthread::idas described in 26.8 [alg.sorting], unspecified except thatP(x, y)isfalsewhenxandyboth represent the same thread of execution, or when neither represents a thread of execution.strong_ordering::lessifP(x, y)istrue. Otherwise,strong_ordering::greaterifP(y, x)istrue. Otherwise,strong_ordering::equal.