<thread>

public member type
<thread>

std::thread::id

class thread::id;
Thread id
Values of this type are returned by thread::get_id and this_thread::get_id to identify threads.

The value of a default-constructed thread::id object identifies non-joinable threads, and thus compares equal to the value returned by member thread::get_id of any such threads.

For joinable threads, thread::get_id returns a unique value of this type that does not compare equal the one returned for any other joinable or non-joinable thread.

Note that certain library implementations may reutilize the thread::id value of a terminated thread that can no longer be joined.

Member functions

id() noexcept; //default constructor
Constructs the thread::id value that represents all non-joinable threads.
thread::id objects are trivially copyable

Non-member function overloads

bool operator== (thread::id lhs, thread::id rhs) noexcept;
bool operator!= (thread::id lhs, thread::id rhs) noexcept;
bool operator< (thread::id lhs, thread::id rhs) noexcept;
bool operator<= (thread::id lhs, thread::id rhs) noexcept;
bool operator> (thread::id lhs, thread::id rhs) noexcept;
bool operator>= (thread::id lhs, thread::id rhs) noexcept;
Two thread::id object compare equal if they represent the same joinable thread, or if they both represent non-joinable threads.
The order established by relational operators is an implementation-defined stable total order, allowing its use as keys for associative containers.
template <class charT, class traits>
basic_ostream<chasrT, traits>& operator<< (basic_ostream<charT,traits>& os, thread::id id);
Inserts a textual representation of id into os (in an implementation-specific manner).
Inserting two thread::id object that compare equal, generates the same textual representation. Inserting different thread::id values generates different representations.

Non-member class specializations

template <class T> struct hash; //generic template declaration
template<> struct hash<thread::id>;
Unary function object class that defines the specialization of hash for objects of type thread::id (see hash).

See also