How to implement a custom hash function for __uint128_t?

Hi all,
How can I implement a hash function for a __uint128_t type that is
compatible with Boost?
I tried this:
#include

On Sun, Dec 9, 2012 at 3:37 PM, Scott Smedley
Hi all,
How can I implement a hash function for a __uint128_t type that is compatible with Boost?
I tried this:
#include
#include #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_caststd::size_t(x); }
int main (int argc, char *argv[]) { std::unordered_set
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. :)
Try rearranging and putting the hash inclusion after your custom definition of hash_value? I'm guessing since your custom hash_value isn't findable by ADL, you'd need it declared prior to its use with hash.hpp...? - Jeff

On 10 December 2012 03:18, Jeffrey Lee Hellrung, Jr.
Try rearranging and putting the hash inclusion after your custom definition of hash_value? I'm guessing since your custom hash_value isn't findable by ADL, you'd need it declared prior to its use with hash.hpp...?
Yes, you might need to put it in the boost namespace. But, I've just checked support into trunk and, if all goes well, it will be in the next release.
participants (3)
-
Daniel James
-
Jeffrey Lee Hellrung, Jr.
-
Scott Smedley