aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-06-21 19:13:35 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-06-21 19:13:35 +0100
commit1eaf3b243d208af51327e8f3a5940279c93e4d9a (patch)
treed4317c39904c4345882f5ae5a71bd6b8d60e7160 /src/libutil
parent3a8bb197fb08ef3832e45f7ee270cc66bc6ea224 (diff)
downloadrspamd-1eaf3b243d208af51327e8f3a5940279c93e4d9a.tar.gz
rspamd-1eaf3b243d208af51327e8f3a5940279c93e4d9a.zip
[Minor] Move stuff
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/cxx/hash_util.hxx39
-rw-r--r--src/libutil/cxx/util.hxx40
2 files changed, 39 insertions, 40 deletions
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<typename T>
+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);
+ }
+ auto operator()(const std::shared_ptr<T> &a, const T &b) const {
+ return (*a) == b;
+ }
+ 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 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);
+ }
+};
/* 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
@@ -30,46 +30,6 @@
namespace rspamd {
/*
- * Transparent smart pointers hashing
- */
-template<typename T>
-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);
- }
- auto operator()(const std::shared_ptr<T> &a, const T &b) const {
- return (*a) == b;
- }
- 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 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);
- }
-};
-
-/*
* Creates std::array from a standard C style array with automatic size calculation
*/
template <typename... Ts>