diff --git a/hash/test/Jamfile.v2 b/hash/test/Jamfile.v2 old mode 100755 new mode 100644 diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index c7de2c5..3e5ab5b 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -1,11 +1,17 @@ -// Copyright 2005-2009 Daniel James. +// Copyright 2005-2014 Daniel James. // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // Based on Peter Dimov's proposal // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf // issue 6.18. +// +// This also contains public domain code from MurmurHash. From the +// MurmurHash header: + +// MurmurHash3 was written by Austin Appleby, and is placed in the public +// domain. The author hereby disclaims copyright to this source code. #if !defined(BOOST_FUNCTIONAL_HASH_HASH_HPP) #define BOOST_FUNCTIONAL_HASH_HASH_HPP @@ -18,6 +24,7 @@ #include #include #include +#include #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) #include @@ -45,6 +52,12 @@ #define BOOST_HASH_CHAR_TRAITS char_traits #endif +#if defined(_MSC_VER) +# define BOOST_FUNCTIONAL_HASH_ROTL32(x, r) _rotl(x,r) +#else +# define BOOST_FUNCTIONAL_HASH_ROTL32(x, r) (x << r) | (x >> (32 - r)) +#endif + namespace boost { namespace hash_detail @@ -192,6 +205,51 @@ namespace boost return seed; } + + template + inline void hash_combine_impl(SizeT& seed, SizeT value) + { + seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2); + } + + template + inline void hash_combine_impl(boost::uint32_t& h1, + boost::uint32_t k1) + { + const uint32_t c1 = 0xcc9e2d51; + const uint32_t c2 = 0x1b873593; + + k1 *= c1; + k1 = BOOST_FUNCTIONAL_HASH_ROTL32(k1,15); + k1 *= c2; + + h1 ^= k1; + h1 = BOOST_FUNCTIONAL_HASH_ROTL32(h1,13); + h1 = h1*5+0xe6546b64; + } + + +// Don't define 64-bit hash combine on platforms with 64 bit integers, +// and also not for 32-bit gcc as it warns about the 64-bit constant. +#if !defined(BOOST_NO_INT64_T) && \ + !(defined(__GNUC__) && ULONG_MAX == 0xffffffff) + + template + inline void hash_combine_impl(boost::uint64_t& h, + boost::uint64_t k) + { + const uint64_t m = UINT64_C(0xc6a4a7935bd1e995); + const int r = 47; + + k *= m; + k ^= k >> r; + k *= m; + + h ^= k; + h *= m; + } + +#endif // BOOST_NO_INT64_T } template @@ -252,7 +310,7 @@ namespace boost inline void hash_combine(std::size_t& seed, T const& v) { boost::hash hasher; - seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); + return boost::hash_detail::hash_combine_impl(seed, hasher(v)); } #if defined(BOOST_MSVC) @@ -483,6 +541,7 @@ namespace boost } #undef BOOST_HASH_CHAR_TRAITS +#undef BOOST_FUNCTIONAL_HASH_ROTL32 #if defined(BOOST_MSVC) #pragma warning(pop) diff --git a/meta/libraries.json b/meta/libraries.json new file mode 100644 index 0000000..ff2f4cf --- /dev/null +++ b/meta/libraries.json @@ -0,0 +1,88 @@ +[ + { + "key": "functional", + "boost-version": "1.16.0", + "name": "Functional", + "authors": [ + "Mark Rodgers" + ], + "description": "The Boost.Function library contains a family of class templates that are function object wrappers.", + "std-proposal": false, + "std-tr1": false, + "category": [ + "Function-objects" + ] + }, + { + "key": "functional/factory", + "boost-version": "1.43.0", + "name": "Functional/Factory", + "authors": [ + "Tobias Schwinger" + ], + "description": "Function object templates for dynamic and static object creation", + "documentation": "factory/", + "std-proposal": false, + "std-tr1": false, + "category": [ + "Function-objects" + ], + "maintainers": [ + "Tobias Schwinger " + ] + }, + { + "key": "functional/forward", + "boost-version": "1.43.0", + "name": "Functional/Forward", + "authors": [ + "Tobias Schwinger" + ], + "description": "Adapters to allow generic function objects to accept arbitrary arguments", + "documentation": "forward/", + "std-proposal": false, + "std-tr1": false, + "category": [ + "Function-objects" + ], + "maintainers": [ + "Tobias Schwinger " + ] + }, + { + "key": "functional/hash", + "boost-version": "1.33.0", + "name": "Functional/Hash", + "authors": [ + "Daniel James" + ], + "maintainers": [ + "Daniel James " + ], + "description": "A TR1 hash function object that can be extended to hash user defined types.", + "documentation": "hash/", + "std-proposal": false, + "std-tr1": true, + "category": [ + "Function-objects" + ] + }, + { + "key": "functional/overloaded_function", + "boost-version": "1.50.0", + "name": "Functional/Overloaded Function", + "authors": [ + "Lorenzo Caminiti" + ], + "description": "Overload different functions into a single function object.", + "documentation": "overloaded_function/", + "std-proposal": false, + "std-tr1": false, + "category": [ + "Function-objects" + ], + "maintainers": [ + "Lorenzo Caminiti " + ] + } +] \ No newline at end of file