diff --git a/src/IntrusivePtr.h b/src/IntrusivePtr.h index ce44f5e441..7ad37031c8 100644 --- a/src/IntrusivePtr.h +++ b/src/IntrusivePtr.h @@ -4,6 +4,7 @@ #include #include +#include namespace zeek { @@ -292,3 +293,13 @@ auto operator!=(const zeek::IntrusivePtr& x, const zeek::IntrusivePtr& y) } } // namespace zeek + +// -- hashing ------------------------------------------------ + +namespace std { +template struct hash> { + // Hash of intrusive pointer is the same as hash of the raw pointer it holds. + size_t operator()(const zeek::IntrusivePtr& v) const noexcept + { return std::hash{}(v.get()); } +}; +}