std::hash
| template<size_t N> struct hash<bitset<N>>; |  | (since C++11) | 
|---|
模板的专门化std::hash为std::bitset<N>允许用户获取类型对象的散列。std::bitset<N>...
例
下面的代码显示了在几个位集上使用的散列函数的一个可能输出:
二次
#include <iostream>
#include <bitset>
#include <functional>
 
int main()
{
    std::bitset<4> b1(1);
    std::bitset<4> b2(2);
    std::bitset<4> b3(b2);
 
    std::hash<std::bitset<4>> hash_fn;
 
    size_t h1 = hash_fn(b1);
    size_t h2 = hash_fn(b2);
    size_t h3 = hash_fn(b3);
 
    std::cout << h1 << '\n';
    std::cout << h2 << '\n';
    std::cout << h3 << '\n';
}二次
产出:
二次
67918732
118251589
118251589二次
另见
| hash (C++11) | hash function object (class template) | 
|---|
 © cppreference.com在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com

