Skip to content

Commit 6b5cd5c

Browse files
authored
Update 003_stl_std_hash_std_bitset.cpp
1 parent ad8d3f6 commit 6b5cd5c

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed
Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
1-
1
1+
#include <bitset>
2+
#include <iostream>
3+
#include <functional>
4+
5+
int main()
6+
{
7+
std::bitset<4> b1{0}, b2{42};
8+
std::bitset<8> b3{0}, b4{42};
9+
10+
std::hash<std::bitset<4>> hash_fn4;
11+
std::hash<std::bitset<8>> hash_fn8;
12+
using bin64 = std::bitset<64>;
13+
14+
std::cout
15+
<< bin64{hash_fn4(b1)} << " = " << hash_fn4(b1) << '\n'
16+
<< bin64{hash_fn4(b2)} << " = " << hash_fn4(b2) << '\n'
17+
<< bin64{hash_fn8(b3)} << " = " << hash_fn8(b3) << '\n'
18+
<< bin64{hash_fn8(b4)} << " = " << hash_fn8(b4) << '\n';
19+
}

0 commit comments

Comments
 (0)