Use custom hash functions as Boost.ContainerHash requires C++11.

This commit is contained in:
Ion Gaztañaga
2023-12-31 23:45:45 +01:00
parent a15334305d
commit 8b4297b1db
13 changed files with 25 additions and 62 deletions
+10 -3
View File
@@ -13,20 +13,27 @@
#include <boost/intrusive/set.hpp>
#include <boost/intrusive/unordered_set.hpp>
#include <cstring>
using namespace boost::intrusive;
#include <string>
// Hash function for strings
struct StrHasher
{
std::size_t operator()(const char *str) const
{
//Simple example, use favorite hash function (like boost::hash_combine)
std::size_t seed = 0;
for(; *str; ++str) boost::hash_combine(seed, *str);
for(; *str; ++str){
std::size_t x = std::size_t(*str);
x = ((x >> 16) ^ x) * 0x45d9f3b;
x = (x >> 16) ^ x;
seed += x;
}
return seed;
}
};
using namespace boost::intrusive;
class Expensive : public set_base_hook<>, public unordered_set_base_hook<>
{
std::string key_;