From e2bbb5b07edba855b3360ecd6ecd9b6bdb0646f1 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 6 Sep 2021 12:54:51 +0200 Subject: [PATCH] BLI: add default hash for shared_ptr and reference_wrapper This makes it easier to use these types as keys in Map, Set and VectorSet. --- source/blender/blenlib/BLI_hash.hh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/source/blender/blenlib/BLI_hash.hh b/source/blender/blenlib/BLI_hash.hh index fbed321534c..11ff7d040aa 100644 --- a/source/blender/blenlib/BLI_hash.hh +++ b/source/blender/blenlib/BLI_hash.hh @@ -250,6 +250,20 @@ template struct DefaultHash> { } }; +template struct DefaultHash> { + uint64_t operator()(const std::shared_ptr &value) const + { + return get_default_hash(value.get()); + } +}; + +template struct DefaultHash> { + uint64_t operator()(const std::reference_wrapper &value) const + { + return get_default_hash(value.get()); + } +}; + template struct DefaultHash> { uint64_t operator()(const std::pair &value) const {