Skip to content

Commit ee42ec1

Browse files
committed
implement the standard lib hash function for std::pair
1 parent 7d1f1bb commit ee42ec1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/cpp-utility/std/Hash.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#pragma once
2+
3+
namespace std {
4+
/// Partial specializations for pair types.
5+
template<typename T1, typename T2>
6+
struct hash<pair<T1, T2>> : public __hash_base<size_t, pair<T1, T2>> {
7+
size_t operator()(pair<T1, T2> p) const noexcept {
8+
return hash<T1>()(p.first) ^ hash<T2>()(p.second);
9+
}
10+
};
11+
} // namespace std

0 commit comments

Comments
 (0)