mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Add std::hash specialization for IntrusivePtr
This commit is contained in:
parent
cffc8fa13c
commit
583310f6dd
1 changed files with 11 additions and 0 deletions
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
namespace zeek {
|
namespace zeek {
|
||||||
|
|
||||||
|
@ -292,3 +293,13 @@ auto operator!=(const zeek::IntrusivePtr<T>& x, const zeek::IntrusivePtr<U>& y)
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace zeek
|
} // namespace zeek
|
||||||
|
|
||||||
|
// -- hashing ------------------------------------------------
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
template <class T> struct hash<zeek::IntrusivePtr<T>> {
|
||||||
|
// Hash of intrusive pointer is the same as hash of the raw pointer it holds.
|
||||||
|
size_t operator()(const zeek::IntrusivePtr<T>& v) const noexcept
|
||||||
|
{ return std::hash<T*>{}(v.get()); }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue