From fd7ac4e5cae10501b510187687d3cdb92d717c7f Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Tue, 18 Oct 2022 10:26:13 +0200 Subject: [PATCH] Allow hashmaps of String --- lib/base/string.cpp | 5 +++++ lib/base/string.hpp | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/lib/base/string.cpp b/lib/base/string.cpp index eec5b8372..e4e5c273c 100644 --- a/lib/base/string.cpp +++ b/lib/base/string.cpp @@ -461,3 +461,8 @@ String::ConstIterator icinga::range_end(const String& x) { return x.End(); } + +std::size_t std::hash::operator()(const String& s) const noexcept +{ + return std::hash{}(s.GetData()); +} diff --git a/lib/base/string.hpp b/lib/base/string.hpp index b9290eeee..10ddaf977 100644 --- a/lib/base/string.hpp +++ b/lib/base/string.hpp @@ -7,6 +7,7 @@ #include "base/object.hpp" #include #include +#include #include #include @@ -178,6 +179,12 @@ String::ConstIterator range_end(const String& x); } +template<> +struct std::hash +{ + std::size_t operator()(const icinga::String& s) const noexcept; +}; + extern template class std::vector; namespace boost