Fix for non-cpp11 compiler

This commit is contained in:
halx99 2021-09-30 11:42:35 +08:00 committed by GitHub
parent dbced76d85
commit 4852708894
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -230,41 +230,8 @@ namespace pugi {
return !(*this == r);
}
};
template <typename Ch, typename Tr = std::char_traits<Ch> >
struct basic_string_view_hash {
typedef basic_string_view<Ch, Tr> argument_type;
typedef std::size_t result_type;
template <typename Al>
result_type operator()(const std::basic_string<Ch, Tr, Al>& r) const {
return (*this)(argument_type(r.c_str(), r.size()));
}
result_type operator()(const argument_type& r) const {
// Modified, from libstdc++
// An implementation attempt at Fowler No Voll, 1a.
// Supposedly, used in MSVC,
// GCC (libstdc++) uses MurmurHash of some sort for 64-bit though...?
// But, well. Can't win them all, right?
// This should normally only apply when NOT using boost,
// so this should almost never be tapped into...
std::size_t hash = 0;
const unsigned char* cptr = reinterpret_cast<const unsigned char*>(r.data());
for (std::size_t sz = r.size(); sz != 0; --sz) {
hash ^= static_cast<size_t>(*cptr++);
hash *= static_cast<size_t>(1099511628211ULL);
}
return hash;
}
};
} // namespace pugi
namespace std {
template <typename Ch, typename Tr>
struct hash<pugi::basic_string_view<Ch, Tr> > : pugi::basic_string_view_hash<Ch, Tr> {};
} // namespace std
namespace pugi {
typedef basic_string_view<char> string_view;
typedef basic_string_view<wchar_t> wstring_view;