From 6753d4b5074fb502a439c2d3ec4f26974353af99 Mon Sep 17 00:00:00 2001 From: nobody Date: Fri, 10 Aug 2007 10:32:21 +0000 Subject: [PATCH] Add overloads of hash_value for more built in types. They're not strictly needed and aren't in the original specifiction but they avoid a warning. See ticket #1095 for details. [SVN r38563] --- hash/doc/ref.xml | 30 ++++++++++++++++ include/boost/functional/hash/hash.hpp | 48 ++++++++++++++++++++++---- 2 files changed, 71 insertions(+), 7 deletions(-) diff --git a/hash/doc/ref.xml b/hash/doc/ref.xml index f55f44d..4925687 100644 --- a/hash/doc/ref.xml +++ b/hash/doc/ref.xml @@ -515,6 +515,36 @@ for(; first != last; ++first) Implementation of the hash function. + + std::size_t + bool + + + + std::size_t + char + + + + std::size_t + signed char + + + + std::size_t + unsigned char + + + + std::size_t + short + + + + std::size_t + unsigned short + + std::size_t int diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index cf6da93..ca13e03 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -34,17 +34,21 @@ namespace boost { -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) - // Borland complains about an ambiguous function overload - // when compiling boost::hash. std::size_t hash_value(bool); -#endif - + std::size_t hash_value(char); + std::size_t hash_value(unsigned char); + std::size_t hash_value(signed char); + std::size_t hash_value(short); + std::size_t hash_value(unsigned short); std::size_t hash_value(int); std::size_t hash_value(unsigned int); std::size_t hash_value(long); std::size_t hash_value(unsigned long); +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) + std::size_t hash_value(wchar_t); +#endif + #if defined(BOOST_HAS_LONG_LONG) std::size_t hash_value(long long); std::size_t hash_value(unsigned long long); @@ -137,12 +141,35 @@ namespace boost } } -#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551)) inline std::size_t hash_value(bool v) { return static_cast(v); } -#endif + + inline std::size_t hash_value(char v) + { + return static_cast(v); + } + + std::size_t hash_value(unsigned char v) + { + return static_cast(v); + } + + std::size_t hash_value(signed char v) + { + return static_cast(v); + } + + inline std::size_t hash_value(short v) + { + return static_cast(v); + } + + inline std::size_t hash_value(unsigned short v) + { + return static_cast(v); + } inline std::size_t hash_value(int v) { @@ -164,6 +191,13 @@ namespace boost return static_cast(v); } +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) + std::size_t hash_value(wchar_t v) + { + return static_cast(v); + } +#endif + #if defined(BOOST_HAS_LONG_LONG) inline std::size_t hash_value(long long v) {