From: Vsevolod Stakhov Date: Tue, 21 Jun 2022 18:13:35 +0000 (+0100) Subject: [Minor] Move stuff X-Git-Tag: 3.3~179 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1eaf3b243d208af51327e8f3a5940279c93e4d9a;p=rspamd.git [Minor] Move stuff --- diff --git a/src/libserver/css/css_rule.hxx b/src/libserver/css/css_rule.hxx index 3385a0de1..acf44ba86 100644 --- a/src/libserver/css/css_rule.hxx +++ b/src/libserver/css/css_rule.hxx @@ -23,6 +23,7 @@ #include "css_parser.hxx" #include "contrib/robin-hood/robin_hood.h" #include "libutil/cxx/util.hxx" +#include "libutil/cxx/hash_util.hxx" #include #include diff --git a/src/libutil/cxx/hash_util.hxx b/src/libutil/cxx/hash_util.hxx index 6d20ddb93..d8529774e 100644 --- a/src/libutil/cxx/hash_util.hxx +++ b/src/libutil/cxx/hash_util.hxx @@ -24,6 +24,45 @@ namespace rspamd { +/* + * Transparent smart pointers hashing + */ +template +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); + } + auto operator()(const std::shared_ptr &a, const T &b) const { + return (*a) == b; + } + 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 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); + } +}; /* Enable lookup by string view */ struct smart_str_equal { diff --git a/src/libutil/cxx/util.hxx b/src/libutil/cxx/util.hxx index 68165569e..88a022954 100644 --- a/src/libutil/cxx/util.hxx +++ b/src/libutil/cxx/util.hxx @@ -29,46 +29,6 @@ */ namespace rspamd { -/* - * Transparent smart pointers hashing - */ -template -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); - } - auto operator()(const std::shared_ptr &a, const T &b) const { - return (*a) == b; - } - 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 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); - } -}; - /* * Creates std::array from a standard C style array with automatic size calculation */