|
Boost Users : |
Subject: [Boost-users] How to implement a custom hash function for __uint128_t?
From: Scott Smedley (scott_at_[hidden])
Date: 2012-12-09 18:37:59
Hi all,
How can I implement a hash function for a __uint128_t type that is
compatible with Boost?
I tried this:
#include <boost/functional/hash.hpp>
#include <unordered_set>
#ifdef USE_64
typedef uint64_t MyId; // works fine
#else
typedef __uint128_t MyId;
#endif
inline std::size_t hash_value (const MyId &x)
{
// not a very good hash function, but I just want to get it working first!
return static_cast<std::size_t>(x);
}
int main (int argc, char *argv[])
{
std::unordered_set<MyId, boost::hash<MyId>> s;
s.insert(42);
}
but I get 144 lines of errors (!) using g++-4.7.2 with Boost v1.51.0
on 64-bit Scientific Linux 6.2:
error: no matching function for call to 'hash_value(const __int128 unsigned&)'
Any pointers/help would be muchly appreciated.
Scott. :)
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net