Allow hashmaps of String

This commit is contained in:
Alexander A. Klimov 2022-10-18 10:26:13 +02:00
parent 449a3c14cf
commit fd7ac4e5ca
2 changed files with 12 additions and 0 deletions

View File

@ -461,3 +461,8 @@ String::ConstIterator icinga::range_end(const String& x)
{ {
return x.End(); return x.End();
} }
std::size_t std::hash<String>::operator()(const String& s) const noexcept
{
return std::hash<std::string>{}(s.GetData());
}

View File

@ -7,6 +7,7 @@
#include "base/object.hpp" #include "base/object.hpp"
#include <boost/range/iterator.hpp> #include <boost/range/iterator.hpp>
#include <boost/utility/string_view.hpp> #include <boost/utility/string_view.hpp>
#include <functional>
#include <string> #include <string>
#include <iosfwd> #include <iosfwd>
@ -178,6 +179,12 @@ String::ConstIterator range_end(const String& x);
} }
template<>
struct std::hash<icinga::String>
{
std::size_t operator()(const icinga::String& s) const noexcept;
};
extern template class std::vector<icinga::String>; extern template class std::vector<icinga::String>;
namespace boost namespace boost