operator<<(std::thread::id)
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Concurrency support library
(C++11)
(C++20)
(C++11)
(C++11)
(C++20)
(C++26)
(C++26)
(C++20)
(C++26)
(C++20)
(C++26)
(C++26)
(C++26)
(C++26)
(C++26)
(C++26)
(C++11)
(C++11)
(C++17)
(C++11)
(C++14)
(C++11)
(C++11)
(C++11)
(C++11)(C++11)(C++11)(C++11)(C++11)(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++20)(C++20)
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
(C++26)
(C++26)
(C++26)
(C++11)
(C++20)
(C++11)
(C++11)(deprecated in C++20)
(C++11)(deprecated in C++20)
(C++11)
(C++11)
(C++11)(deprecated in C++26)
(C++11)
(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++11)(C++11)
(C++26)(C++26)
(C++26)(C++26)
(C++11)
(C++20)(C++20)
(C++20)
(C++20)
(C++11)(C++11)
(C++11)(C++11)
(C++20)(C++20)
(C++20)(C++20)
(C++20)
(C++20)
std::thread::id
Member functions
Non-member functions
(until C++20)(until C++20)(until C++20)(until C++20)(until C++20)(C++20)
operator<<
Helper classes
(C++23)
Defined in header
<thread>
template< class CharT, class Traits >
(since C++11)
std::basic_ostream <CharT,Traits>&
Writes a textual representation of a thread identifier id to the output stream ost.
If two thread identifiers compare equal, they have identical textual representations; if they do not compare equal, their representations are distinct.
Contents
[edit] Parameters
ost
-
output stream to insert the data into
id
-
thread identifier
[edit] Return value
ost
[edit] Exceptions
May throw implementation-defined exceptions.
[edit] Example
Run this code
#include <chrono> #include <iostream> #include <thread> using namespace std::chrono; int main() { std::thread t1([]{ std::this_thread::sleep_for (256ms); }); std::thread t2([]{ std::this_thread::sleep_for (512ms); }); std::clog << t1.get_id() << '\n' << t2.get_id() << '\n'; t1.join(); t2.join(); }
Possible output:
141592653589793 141421356237309