From d6a5c9c435caff0f28e6f81dd504e4a5de57efc6 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 13 Oct 2007 16:34:09 +0000 Subject: [PATCH] New attempt at fixing the function pointer hash on the Sun compilers. I think I was barking up the wrong tree - it could be that when calling hash_value with a function pointer the compiler was choosing the hash_value(bool) overload over the hash_value(T*) overload, so instead I'm trying to call the correct one by giving it a template parameter. Another alternative would be to calculate the hash function inside boost::hash. Unfortunately, if I'm right, this means that other calls to hash_value will go wrong for function pointers. [SVN r39972] --- include/boost/functional/hash/hash.hpp | 28 ++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index 1ffbc24..e9a9a1c 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -28,10 +28,6 @@ #include #endif -#if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) -#include -#endif - namespace boost { std::size_t hash_value(bool); @@ -213,15 +209,9 @@ namespace boost template std::size_t hash_value(T* v) #endif { -#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) std::size_t x = static_cast( reinterpret_cast(v)); -#else - std::size_t x = static_cast( - boost::is_function::value ? - reinterpret_cast((void*) v) : - reinterpret_cast(v)); -#endif + return x + (x >> 3); } @@ -475,10 +465,14 @@ namespace boost struct hash : public std::unary_function { - std::size_t operator()(T* v) const \ - { \ - return boost::hash_value(v); \ - } \ + std::size_t operator()(T* v) const + { +#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590) + return boost::hash_value(v); +#else + return boost::hash_value(v); +#endif + } }; #else namespace hash_detail @@ -495,7 +489,11 @@ namespace boost { std::size_t operator()(T val) const { +#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 590) return boost::hash_value(val); +#else + return boost::hash_value(val); +#endif } }; };