aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/cxx/local_shared_ptr.hxx
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2021-07-23 15:09:19 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2021-07-23 15:09:19 +0100
commit5b17d5900cefe0f220554ff7a5235de308f2abbd (patch)
treeade7299492e227655fb67fb2828bb831a2e29c19 /src/libutil/cxx/local_shared_ptr.hxx
parente75e11f87bf6c7136d171fa14cb4b5f9509c52f4 (diff)
downloadrspamd-5b17d5900cefe0f220554ff7a5235de308f2abbd.tar.gz
rspamd-5b17d5900cefe0f220554ff7a5235de308f2abbd.zip
[Minor] Add std::hash specialisation + tests
Diffstat (limited to 'src/libutil/cxx/local_shared_ptr.hxx')
-rw-r--r--src/libutil/cxx/local_shared_ptr.hxx14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libutil/cxx/local_shared_ptr.hxx b/src/libutil/cxx/local_shared_ptr.hxx
index 81cbe6d08..cf0875813 100644
--- a/src/libutil/cxx/local_shared_ptr.hxx
+++ b/src/libutil/cxx/local_shared_ptr.hxx
@@ -340,14 +340,20 @@ private:
namespace std {
template <class T>
struct hash<rspamd::local_shared_ptr<T>> {
- inline auto operator()(const rspamd::local_shared_ptr<T> &p) const noexcept -> auto {
- return hash<T *>()(p.get());
+ inline auto operator()(const rspamd::local_shared_ptr<T> &p) const -> auto {
+ if (!p) {
+ throw std::logic_error("no hash for dangling pointer");
+ }
+ return hash<T>()(*p.get());
}
};
template <class T>
struct hash<rspamd::local_weak_ptr<T>> {
- inline auto operator()(const rspamd::local_weak_ptr<T> &p) const noexcept -> auto {
- return hash<T *>()(p.get());
+ inline auto operator()(const rspamd::local_weak_ptr<T> &p) const -> auto {
+ if (!p) {
+ throw std::logic_error("no hash for dangling pointer");
+ }
+ return hash<T>()(*p.get());
}
};