33 Thread support library [thread]

33.3 Threads [thread.threads]

33.3.2 Class thread [thread.thread.class]

33.3.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;
  bool operator!=(thread::id x, thread::id y) noexcept;
  bool operator<(thread::id x, thread::id y) noexcept;
  bool operator<=(thread::id x, thread::id y) noexcept;
  bool operator>(thread::id x, thread::id y) noexcept;
  bool 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);

  // Hash support
  template <class T> struct hash;
  template <> struct hash<thread::id>;
}

An object of type thread​::​id provides a unique identifier for each thread of execution and a single distinct value for all thread objects 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 the thread​::​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 shall be a trivially copyable class. 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]

id() noexcept;

Effects: Constructs an object of type id.

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.

bool operator!=(thread::id x, thread::id y) noexcept;

Returns: !(x == y)

bool operator<(thread::id x, thread::id y) noexcept;

Returns: A value such that operator< is a total ordering as described in [alg.sorting].

bool operator<=(thread::id x, thread::id y) noexcept;

Returns: !(y < x).

bool operator>(thread::id x, thread::id y) noexcept;

Returns: y < x.

bool operator>=(thread::id x, thread::id y) noexcept;

Returns: !(x < y).

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 into out. For two objects of type thread​::​id x and y, if x == y the thread​::​id objects shall have the same text representation and if x != y the thread​::​id objects shall have distinct text representations.

Returns: out.

template <> struct hash<thread::id>;

The specialization is enabled ([unord.hash]).