diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-06-15 14:36:14 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-06-15 14:36:14 +0100 |
commit | 0a8d31c8959c2470b2e53646f2926c1f3d109562 (patch) | |
tree | 31b84b032cbca6fcc5cb0a373d3576e565ab3206 | |
parent | 691323fc2b02fac019fa6420606a2a380ac5f9ff (diff) | |
download | rspamd-0a8d31c8959c2470b2e53646f2926c1f3d109562.tar.gz rspamd-0a8d31c8959c2470b2e53646f2926c1f3d109562.zip |
[Minor] Improve smart hash helper
-rw-r--r-- | src/libutil/cxx/util.hxx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/libutil/cxx/util.hxx b/src/libutil/cxx/util.hxx index 3eeb6d20d..fa9aa1802 100644 --- a/src/libutil/cxx/util.hxx +++ b/src/libutil/cxx/util.hxx @@ -31,7 +31,7 @@ namespace rspamd { * Transparent smart pointers hashing */ template<typename T> -struct shared_ptr_equal { +struct smart_ptr_equal { using is_transparent = void; /* We want to find values in a set of shared_ptr by reference */ auto operator()(const std::shared_ptr<T> &a, const std::shared_ptr<T> &b) const { return (*a) == (*b); @@ -42,14 +42,26 @@ struct shared_ptr_equal { auto operator()(const T &a, const std::shared_ptr<T> &b) const { return a == (*b); } + auto operator()(const std::unique_ptr<T> &a, const std::unique_ptr<T> &b) const { + return (*a) == (*b); + } + auto operator()(const std::unique_ptr<T> &a, const T &b) const { + return (*a) == b; + } + auto operator()(const T &a, const std::unique_ptr<T> &b) const { + return a == (*b); + } }; template<typename T> -struct shared_ptr_hash { +struct smart_ptr_hash { using is_transparent = void; /* We want to find values in a set of shared_ptr by reference */ auto operator()(const std::shared_ptr<T> &a) const { return std::hash<T>()(*a); } + auto operator()(const std::unique_ptr<T> &a) const { + return std::hash<T>()(*a); + } auto operator()(const T &a) const { return std::hash<T>()(a); } |