From: Vsevolod Stakhov Date: Tue, 15 Jun 2021 13:36:14 +0000 (+0100) Subject: [Minor] Improve smart hash helper X-Git-Tag: 3.0~300 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0a8d31c8959c2470b2e53646f2926c1f3d109562;p=rspamd.git [Minor] Improve smart hash helper --- 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 -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 &a, const std::shared_ptr &b) const { return (*a) == (*b); @@ -42,14 +42,26 @@ struct shared_ptr_equal { auto operator()(const T &a, const std::shared_ptr &b) const { return a == (*b); } + auto operator()(const std::unique_ptr &a, const std::unique_ptr &b) const { + return (*a) == (*b); + } + auto operator()(const std::unique_ptr &a, const T &b) const { + return (*a) == b; + } + auto operator()(const T &a, const std::unique_ptr &b) const { + return a == (*b); + } }; template -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 &a) const { return std::hash()(*a); } + auto operator()(const std::unique_ptr &a) const { + return std::hash()(*a); + } auto operator()(const T &a) const { return std::hash()(a); }