[thread.thread.id] (original) (raw)
32 Thread support library [thread]
32.4 Threads [thread.threads]
32.4.2 Class thread [thread.thread.class]
32.4.2.1 Class thread::id [thread.thread.id]
namespace std { class thread::id { public: id() noexcept; };
bool operator==(thread::id x, thread::id y) noexcept; strong_ordering operator<=>(thread::id x, thread::id y) noexcept;
template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& out, thread::id id);
template struct hash; template<> struct hashthread::id; }
An object of type thread::id provides a unique identifier for each thread of execution and a single distinct value for all threadobjects that do not represent a thread of execution ([thread.thread.class]).
Each thread of execution has an associated thread::id object that is not equal to thethread::id object of any other thread of execution and that is not equal to the thread::id object of any thread object that does not represent threads of execution.
thread::id is a trivially copyable class ([class.prop]).
The library may reuse the value of a thread::id of a terminated thread that can no longer be joined.
[ Note
:
Relational operators allow thread::id objects to be used as keys in associative containers.
— end note
]
Postconditions:The constructed object does not represent a thread of execution.
bool operator==(thread::id x, thread::id y) noexcept;
Returns: true only if x and y represent the same thread of execution or neither x nor y represents a thread of execution.
strong_ordering operator<=>(thread::id x, thread::id y) noexcept;
Let be an unspecified total ordering over thread::idas described in [alg.sorting].
Returns: strong_ordering::less if is true.
Otherwise, strong_ordering::greaterif is true.
Otherwise, strong_ordering::equal.
template<class charT, class traits> basic_ostream<charT, traits>& operator<< (basic_ostream<charT, traits>& out, thread::id id);
Effects:Inserts an unspecified text representation of id intoout.
For two objects of type thread::id x and y, if x == y the thread::id objects have the same text representation and if x != y the thread::id objects have distinct text representations.
template<> struct hash<thread::id>;