std::hash<std::thread::id>
cppreference.com
<tbody>
</tbody>
template<> struct hash<std::thread::id>; |
( C++11) | |
| : , |
#include <iostream>
#include <thread>
#include <chrono>
#include <vector>
using namespace std::chrono_literals;
void foo()
{
std::this_thread::sleep_for(10ms);
}
int main()
{
std::vector<std::thread> v;
for(int n = 0; n < 4; ++n)
v.emplace_back(foo);
std::hash<std::thread::id> hasher;
for(auto& t : v) {
std::cout << " " << t.get_id() << " " << hasher(t.get_id()) << '\n';
t.join();
}
}
:
139786440144640 8905351942358389397
139786431751936 9222844670065909738
139786423359232 18199000599186780501
139786414966528 15386662774029264672
(C++11) |
- ( ) |