From 976683836ebcb54269e8f660a8c0addf5229b02a Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 13 Apr 2005 20:24:50 +0000 Subject: [PATCH] Borland workaround for hashing arrays. [SVN r28226] --- include/boost/functional/hash/hash.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index e0e1b42..5a0f560 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -197,11 +197,31 @@ namespace boost } #if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) +#if !defined(__BORLANDC__) template< class T, unsigned N > inline std::size_t hash_value(const T (&array)[N]) { return hash_range(array, array+N); } +#else + // On Borland some type information was lost in the call to hash_combine + // from hash_range, so inline everything here so that doesn't happen. + template< class T, unsigned N > + inline std::size_t hash_value(const T (&array)[N]) + { + std::size_t seed = 0; + T const* first = array; + T const* last = array + N; + + for(; first != last; ++first) + { + seed ^= hash_detail::call_hash::call(*first) + + 0x9e3779b9 + (seed<<6) + (seed>>2); + } + + return seed; + } +#endif #endif #if BOOST_WORKAROUND(__GNUC__, < 3) && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)