commit 1eaf3b2: [Minor] Move stuff
Vsevolod Stakhov
vsevolod at rspamd.com
Tue Jun 21 18:28:03 UTC 2022
Author: Vsevolod Stakhov
Date: 2022-06-21 19:13:35 +0100
URL: https://github.com/rspamd/rspamd/commit/1eaf3b243d208af51327e8f3a5940279c93e4d9a (HEAD -> master)
[Minor] Move stuff
---
src/libserver/css/css_rule.hxx | 1 +
src/libutil/cxx/hash_util.hxx | 39 +++++++++++++++++++++++++++++++++++++++
src/libutil/cxx/util.hxx | 40 ----------------------------------------
3 files changed, 40 insertions(+), 40 deletions(-)
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 <vector>
#include <memory>
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
@@ -29,46 +29,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
*/
More information about the Commits
mailing list