diff --git a/CHANGES.html b/CHANGES.html
index 6e6535832..782e1c071 100644
--- a/CHANGES.html
+++ b/CHANGES.html
@@ -60,6 +60,7 @@ us a note on ns-developers mailing list.
In class Ipv4InterfaceAddress, a new function IsInSameSubnet () is added to check if both the IPv4 addresses are in the same subnet. Also, it is consistent with Ipv6InterfaceAddress::IsInSameSubnet ().
In class ConfigStore, a new Attribue SaveDeprecated allows to not save DEPRECATED Attributes. The default value is false (save DEPRECATED Attributes).
In class TracedCallback, a new function IsEmpty allows to know if the TracedCallback will call any callback.
+A new specialization of std::hash for Ptr allows to use seamlessly Ptrs as keys in unordered_map and unordered_set.
Changes to existing API:
diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index b24fd480f..3c3f25199 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -36,6 +36,7 @@ New user-visible features
- (config-store) OBSOLETE Attributes are not anymore saved.
- (config-store) New ConfigStore::SaveDeprecated Attribute (default false) to avoid to save DEPRECATED attributes.
- (core) Add TracedCallback::IsEmpty to know if a TracedCallback has any callback associated.
+- (core) Add std::hash> to allow seamless use of Ptr as key in unordered_maps.
Bugs fixed
----------
diff --git a/src/core/model/ptr.h b/src/core/model/ptr.h
index 91e342d6c..36ed7a5cc 100644
--- a/src/core/model/ptr.h
+++ b/src/core/model/ptr.h
@@ -695,4 +695,39 @@ Ptr::operator Tester * () const
} // namespace ns3
+
+/****************************************************
+ * Global Functions (outside namespace ns3)
+ ***************************************************/
+
+/**
+ * \ingroup ptr
+ * Hashing functor taking a `Ptr` and returning a @c std::size_t.
+ * For use with `unordered_map` and `unordered_set`.
+ *
+ * \note When a `Ptr` is used in a container the lifetime of the underlying
+ * object is at least as long as the container. In other words,
+ * you need to remove the object from the container when you are done with
+ * it, otherwise the object will persist until the container itself is
+ * deleted.
+ *
+ * \tparam T \deduced The type held by the `Ptr`
+ */
+template
+struct
+std::hash>
+{
+ /**
+ * The functor.
+ * \param p The `Ptr` value to hash.
+ * \return the hash
+ */
+ std::size_t
+ operator () (ns3::Ptr p) const
+ {
+ return std::hash () (ns3::PeekPointer (p));
+ }
+};
+
+
#endif /* PTR_H */