[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/thread/thread/id/hash [Back]  [Original]

std::hash<std::thread::id> cppreference.com
cppreference.com

std::hash<std::thread::id>

cppreference.com
 
C++
(C++20)
(C++20)
(C++11)
(C++20)
/
(C++11)
(C++11)
(C++11)
(C++17)
 
(C++11)
(C++20)
(C++20)
this_thread
(C++11)
(C++11)
(C++11)
(C++11)
(C++20)
(C++11)( C++20)
(C++11)( C++20)
(C++11)( C++20)
(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)
 
 
 
<tbody> </tbody>
template<> struct hash<std::thread::id>;
( C++11)

std::hash std::thread::id .

#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)
-
( ) []

Web Proxy Viewer  |  New URL  |  Original Page