diff options
author | Jacques Lucke <jacques@blender.org> | 2020-06-11 17:16:44 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-06-11 17:16:44 +0300 |
commit | 3d18bd5c5160b7ee8543558053cad9126804dbd6 (patch) | |
tree | e79146b5df833228347212b655da625db559e74c /source/blender/blenlib/BLI_hash.hh | |
parent | 49af2f85c3f1cfee4e2344a9eef5a2cb8bb5905f (diff) |
BLI: define default hash function for const types
Diffstat (limited to 'source/blender/blenlib/BLI_hash.hh')
-rw-r--r-- | source/blender/blenlib/BLI_hash.hh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_hash.hh b/source/blender/blenlib/BLI_hash.hh index 57d5f7f9d8a..de81abd5d7a 100644 --- a/source/blender/blenlib/BLI_hash.hh +++ b/source/blender/blenlib/BLI_hash.hh @@ -97,6 +97,16 @@ template<typename T> struct DefaultHash { } }; +/** + * Use the same hash function for const and non const variants of a type. + */ +template<typename T> struct DefaultHash<const T> { + uint32_t operator()(const T &value) const + { + return DefaultHash<T>{}(value); + } +}; + #define TRIVIAL_DEFAULT_INT_HASH(TYPE) \ template<> struct DefaultHash<TYPE> { \ uint32_t operator()(TYPE value) const \ |