From 4dbfca239007134d269d78bdfb5dc6c7abd41828 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 2 Sep 2020 16:33:43 +0100 Subject: [PATCH] Add std::hash overload for ResourceId to allow use in hashmaps/hashsets --- renderdoc/api/replay/resourceid.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/renderdoc/api/replay/resourceid.h b/renderdoc/api/replay/resourceid.h index c41e5d044..4a17ee77f 100644 --- a/renderdoc/api/replay/resourceid.h +++ b/renderdoc/api/replay/resourceid.h @@ -73,6 +73,7 @@ private: #ifdef RENDERDOC_EXPORTS friend ResourceId ResourceIDGen::GetNewUniqueID(); + friend struct std::hash; #endif }; @@ -83,3 +84,15 @@ Q_DECLARE_METATYPE(ResourceId); #endif DECLARE_REFLECTION_STRUCT(ResourceId); + +// add a std::hash overload so ResourceId can be used in hashmaps +#ifdef RENDERDOC_EXPORTS +namespace std +{ +template <> +struct hash +{ + std::size_t operator()(const ResourceId &id) const { return std::hash()(id.id); } +}; +} +#endif