Boost logo

Boost-Commit :

From: daniel_james_at_[hidden]
Date: 2007-10-13 12:34:10


Author: danieljames
Date: 2007-10-13 12:34:09 EDT (Sat, 13 Oct 2007)
New Revision: 39972
URL: http://svn.boost.org/trac/boost/changeset/39972

Log:
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.

Text files modified:
   trunk/boost/functional/hash/hash.hpp | 28 +++++++++++++---------------
   1 files changed, 13 insertions(+), 15 deletions(-)

Modified: trunk/boost/functional/hash/hash.hpp
==============================================================================
--- trunk/boost/functional/hash/hash.hpp (original)
+++ trunk/boost/functional/hash/hash.hpp 2007-10-13 12:34:09 EDT (Sat, 13 Oct 2007)
@@ -28,10 +28,6 @@
 #include <boost/type_traits/is_const.hpp>
 #endif
 
-#if BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590)
-#include <boost/type_traits/is_function.hpp>
-#endif
-
 namespace boost
 {
     std::size_t hash_value(bool);
@@ -213,15 +209,9 @@
     template <class T> std::size_t hash_value(T* v)
 #endif
     {
-#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 0x590)
         std::size_t x = static_cast<std::size_t>(
            reinterpret_cast<std::ptrdiff_t>(v));
-#else
- std::size_t x = static_cast<std::size_t>(
- boost::is_function<T>::value ?
- reinterpret_cast<std::ptrdiff_t>((void*) v) :
- reinterpret_cast<std::ptrdiff_t>(v));
-#endif
+
         return x + (x >> 3);
     }
 
@@ -475,10 +465,14 @@
     struct hash<T*>
         : public std::unary_function<T*, std::size_t>
     {
- 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<T*>(v);
+#endif
+ }
     };
 #else
     namespace hash_detail
@@ -495,7 +489,11 @@
             {
                 std::size_t operator()(T val) const
                 {
+#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 590)
                     return boost::hash_value(val);
+#else
+ return boost::hash_value<T>(val);
+#endif
                 }
             };
         };


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk