diff --git a/doc/ref.xml b/doc/ref.xml index ca92c20..7da9275 100644 --- a/doc/ref.xml +++ b/doc/ref.xml @@ -479,6 +479,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 bb1394b..56a922f 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -35,17 +35,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) && defined(_M_X64) && defined(_WIN64) // On 64-bit windows std::size_t is a typedef for unsigned long long, which // isn't due to be supported until Boost 1.35. So add support here. @@ -95,12 +99,34 @@ namespace boost // Implementation -#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); + } + + inline std::size_t hash_value(unsigned char v) + { + return static_cast(v); + } + + inline 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) { @@ -122,6 +148,13 @@ namespace boost return static_cast(v); } +#if !defined(BOOST_NO_INTRINSIC_WCHAR_T) + inline std::size_t hash_value(wchar_t v) + { + return static_cast(v); + } +#endif + #if defined(BOOST_HAS_LONG_LONG) && defined(_M_X64) && defined(_WIN64) inline std::size_t hash_value(long long v) { @@ -292,6 +325,15 @@ namespace boost return hash_range(v.begin(), v.end()); } + template + std::size_t hash_value(std::complex const& v) + { + boost::hash hasher; + std::size_t seed = hasher(v.imag()); + seed ^= hasher(v.real()) + (seed<<6) + (seed>>2); + return seed; + } + // // boost::hash // diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index e180961..8b941c5 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -8,6 +8,7 @@ import testing ; project hash-tests : requirements gcc:_GLIBCXX_DEBUG + "gcc:-Wsign-promo -Wextra" ; test-suite functional/hash