From c965760ea1380d64ddd43a5206deffdbf52077b4 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 28 Jan 2014 23:33:25 +0000 Subject: [PATCH 01/10] Improved(?) hash function. Given the existing interface, it's quite tricky to use most popular hash functions without a change, so I'm using a modified version of FNV1a. The current function always starts with a seed of 0 (and will in user functions), so I'm adding the offset each time instead. I'm not sure if that will work as well. --- include/boost/functional/hash/hash.hpp | 41 +++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index c7de2c5..9716e6c 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -192,6 +192,44 @@ namespace boost return seed; } + + template + struct hash_combine_impl + { + inline static void combine(std::size_t& seed, + std::size_t value) + { + seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2); + } + }; + + template <> + struct hash_combine_impl<4> + { + template + inline static void combine(T& seed, std::size_t value) + { + const T offset = 2166136261UL; + const T prime = 16777619UL; + + seed ^= (value + offset); + seed *= prime; + } + }; + + template <> + struct hash_combine_impl<8> + { + template + inline static void combine(T& seed, std::size_t value) + { + const T offset = 14695981039346656037ULL; + const T prime = 1099511628211ULL; + + seed ^= (value + offset); + seed *= prime; + } + }; } template @@ -252,7 +290,8 @@ 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< + sizeof(std::size_t)>::combine(seed, hasher(v)); } #if defined(BOOST_MSVC) From 5b893dfb061187a33143ce8385ae327c5848248d Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 12 Feb 2014 23:48:13 +0000 Subject: [PATCH 02/10] Remove executable flag from jamfile. --- hash/test/Jamfile.v2 | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 hash/test/Jamfile.v2 diff --git a/hash/test/Jamfile.v2 b/hash/test/Jamfile.v2 old mode 100755 new mode 100644 From 64e85476f1f6d65c16f89157f1018f0484c688bb Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 23 Feb 2014 10:16:53 +0000 Subject: [PATCH 03/10] Another try at an improved hash function. This is based on the mix function from MurmurHash. It's not the full algorithm as it's always seeded with 0, and doesn't do a final mix. This should be okay as Boost.Hash doesn't claim to avalanche the bits. --- include/boost/functional/hash/hash.hpp | 86 ++++++++++++++++---------- 1 file changed, 53 insertions(+), 33 deletions(-) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index 9716e6c..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 @@ -193,43 +206,50 @@ namespace boost return seed; } - template - struct hash_combine_impl + template + inline void hash_combine_impl(SizeT& seed, SizeT value) { - inline static void combine(std::size_t& seed, - std::size_t value) - { - seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2); - } - }; + seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2); + } - template <> - struct hash_combine_impl<4> + template + inline void hash_combine_impl(boost::uint32_t& h1, + boost::uint32_t k1) { - template - inline static void combine(T& seed, std::size_t value) - { - const T offset = 2166136261UL; - const T prime = 16777619UL; + const uint32_t c1 = 0xcc9e2d51; + const uint32_t c2 = 0x1b873593; - seed ^= (value + offset); - seed *= prime; - } - }; + k1 *= c1; + k1 = BOOST_FUNCTIONAL_HASH_ROTL32(k1,15); + k1 *= c2; - template <> - struct hash_combine_impl<8> + 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) { - template - inline static void combine(T& seed, std::size_t value) - { - const T offset = 14695981039346656037ULL; - const T prime = 1099511628211ULL; + const uint64_t m = UINT64_C(0xc6a4a7935bd1e995); + const int r = 47; - seed ^= (value + offset); - seed *= prime; - } - }; + k *= m; + k ^= k >> r; + k *= m; + + h ^= k; + h *= m; + } + +#endif // BOOST_NO_INT64_T } template @@ -290,8 +310,7 @@ namespace boost inline void hash_combine(std::size_t& seed, T const& v) { boost::hash hasher; - return boost::hash_detail::hash_combine_impl< - sizeof(std::size_t)>::combine(seed, hasher(v)); + return boost::hash_detail::hash_combine_impl(seed, hasher(v)); } #if defined(BOOST_MSVC) @@ -522,6 +541,7 @@ namespace boost } #undef BOOST_HASH_CHAR_TRAITS +#undef BOOST_FUNCTIONAL_HASH_ROTL32 #if defined(BOOST_MSVC) #pragma warning(pop) From c3154fee78b9746782d8c55acc43cb33558d89d1 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 23 Feb 2014 14:29:48 +0000 Subject: [PATCH 04/10] Add metadata --- meta/libraries.xml | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 meta/libraries.xml diff --git a/meta/libraries.xml b/meta/libraries.xml new file mode 100644 index 0000000..a79b7de --- /dev/null +++ b/meta/libraries.xml @@ -0,0 +1,61 @@ + + + + functional + 1.16.0 + Functional + Mark Rodgers + The Boost.Function library contains a family of + class templates that are function object + wrappers. + false + false + Function-objects + + + functional/hash + 1.33.0 + Functional/Hash + Daniel James + A TR1 hash function object that can be extended to + hash user defined types. + hash/ + false + true + Function-objects + + + functional/factory + 1.43.0 + Functional/Factory + Tobias Schwinger + Function object templates for dynamic and static object creation + factory/ + false + false + Function-objects + + + functional/forward + 1.43.0 + Functional/Forward + Tobias Schwinger + Adapters to allow generic function objects to accept arbitrary arguments + forward/ + false + false + Function-objects + + + functional/overloaded_function + 1.50.0 + Functional/Overloaded Function + Lorenzo Caminiti + Overload different functions into a single function + object. + overloaded_function/ + false + false + Function-objects + + From 8578d4c6a08e5536032e004ec82596231a013142 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 24 Feb 2014 21:40:10 +0000 Subject: [PATCH 05/10] Json meta data. --- meta/libraries.json | 66 +++++++++++++++++++++++++++++++++++++++++++++ meta/libraries.xml | 61 ----------------------------------------- 2 files changed, 66 insertions(+), 61 deletions(-) create mode 100644 meta/libraries.json delete mode 100644 meta/libraries.xml diff --git a/meta/libraries.json b/meta/libraries.json new file mode 100644 index 0000000..fd69e84 --- /dev/null +++ b/meta/libraries.json @@ -0,0 +1,66 @@ +[ + { + "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/hash", + "boost-version": "1.33.0", + "name": "Functional/Hash", + "authors": "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/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" + ] + }, + { + "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" + ] + }, + { + "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" + ] + } +] \ No newline at end of file diff --git a/meta/libraries.xml b/meta/libraries.xml deleted file mode 100644 index a79b7de..0000000 --- a/meta/libraries.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - functional - 1.16.0 - Functional - Mark Rodgers - The Boost.Function library contains a family of - class templates that are function object - wrappers. - false - false - Function-objects - - - functional/hash - 1.33.0 - Functional/Hash - Daniel James - A TR1 hash function object that can be extended to - hash user defined types. - hash/ - false - true - Function-objects - - - functional/factory - 1.43.0 - Functional/Factory - Tobias Schwinger - Function object templates for dynamic and static object creation - factory/ - false - false - Function-objects - - - functional/forward - 1.43.0 - Functional/Forward - Tobias Schwinger - Adapters to allow generic function objects to accept arbitrary arguments - forward/ - false - false - Function-objects - - - functional/overloaded_function - 1.50.0 - Functional/Overloaded Function - Lorenzo Caminiti - Overload different functions into a single function - object. - overloaded_function/ - false - false - Function-objects - - From 50924ef1a87aa550690ae195079f43986030f453 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 24 Feb 2014 22:21:03 +0000 Subject: [PATCH 06/10] Add maintainers to metadata. --- meta/libraries.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meta/libraries.json b/meta/libraries.json index fd69e84..7c278ab 100644 --- a/meta/libraries.json +++ b/meta/libraries.json @@ -16,6 +16,7 @@ "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, @@ -63,4 +64,4 @@ "Function-objects" ] } -] \ No newline at end of file +] From e5f3f1fc422bffc8a95b04c7e076c48eb74a9971 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 24 Feb 2014 22:21:35 +0000 Subject: [PATCH 07/10] Typo --- meta/libraries.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/libraries.json b/meta/libraries.json index 7c278ab..1708853 100644 --- a/meta/libraries.json +++ b/meta/libraries.json @@ -16,7 +16,7 @@ "boost-version": "1.33.0", "name": "Functional/Hash", "authors": "Daniel James", - "maintainers": ["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, From 79cda1d5fdb3c31aa245935467fb5bf15b76921e Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 27 Feb 2014 22:29:01 +0000 Subject: [PATCH 08/10] Update maintainers from /libs/maintainers.txt --- meta/libraries.json | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/meta/libraries.json b/meta/libraries.json index 1708853..4e1692a 100644 --- a/meta/libraries.json +++ b/meta/libraries.json @@ -9,14 +9,15 @@ "std-tr1": false, "category": [ "Function-objects" - ] + ], + "maintainers": "" }, { "key": "functional/hash", "boost-version": "1.33.0", "name": "Functional/Hash", "authors": "Daniel James", - "maintainers": ["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, @@ -36,7 +37,8 @@ "std-tr1": false, "category": [ "Function-objects" - ] + ], + "maintainers": "Tobias Schwinger " }, { "key": "functional/forward", @@ -49,7 +51,8 @@ "std-tr1": false, "category": [ "Function-objects" - ] + ], + "maintainers": "Tobias Schwinger " }, { "key": "functional/overloaded_function", @@ -62,6 +65,7 @@ "std-tr1": false, "category": [ "Function-objects" - ] + ], + "maintainers": "Lorenzo Caminiti " } -] +] \ No newline at end of file From 8a8c098f7fea80d48219b9fc9eabbcac4cd812a9 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 27 Feb 2014 22:46:55 +0000 Subject: [PATCH 09/10] Regenerate libraries.json --- meta/libraries.json | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/meta/libraries.json b/meta/libraries.json index 4e1692a..2ab6730 100644 --- a/meta/libraries.json +++ b/meta/libraries.json @@ -3,21 +3,29 @@ "key": "functional", "boost-version": "1.16.0", "name": "Functional", - "authors": "Mark Rodgers", + "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" ], - "maintainers": "" + "maintainers": [ + "" + ] }, { "key": "functional/hash", "boost-version": "1.33.0", "name": "Functional/Hash", - "authors": "Daniel James", - "maintainers": "Daniel James ", + "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, @@ -30,7 +38,9 @@ "key": "functional/factory", "boost-version": "1.43.0", "name": "Functional/Factory", - "authors": "Tobias Schwinger", + "authors": [ + "Tobias Schwinger" + ], "description": "Function object templates for dynamic and static object creation", "documentation": "factory/", "std-proposal": false, @@ -38,13 +48,17 @@ "category": [ "Function-objects" ], - "maintainers": "Tobias Schwinger " + "maintainers": [ + "Tobias Schwinger " + ] }, { "key": "functional/forward", "boost-version": "1.43.0", "name": "Functional/Forward", - "authors": "Tobias Schwinger", + "authors": [ + "Tobias Schwinger" + ], "description": "Adapters to allow generic function objects to accept arbitrary arguments", "documentation": "forward/", "std-proposal": false, @@ -52,13 +66,17 @@ "category": [ "Function-objects" ], - "maintainers": "Tobias Schwinger " + "maintainers": [ + "Tobias Schwinger " + ] }, { "key": "functional/overloaded_function", "boost-version": "1.50.0", "name": "Functional/Overloaded Function", - "authors": "Lorenzo Caminiti", + "authors": [ + "Lorenzo Caminiti" + ], "description": "Overload different functions into a single function object.", "documentation": "overloaded_function/", "std-proposal": false, @@ -66,6 +84,8 @@ "category": [ "Function-objects" ], - "maintainers": "Lorenzo Caminiti " + "maintainers": [ + "Lorenzo Caminiti " + ] } ] \ No newline at end of file From a20198de14c62120db3bf124d144071c5f9f38b8 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Fri, 28 Feb 2014 00:56:27 +0000 Subject: [PATCH 10/10] Regenerate metadata, alphabetical order + no empty maintainers. --- meta/libraries.json | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/meta/libraries.json b/meta/libraries.json index 2ab6730..ff2f4cf 100644 --- a/meta/libraries.json +++ b/meta/libraries.json @@ -9,27 +9,6 @@ "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" - ], - "maintainers": [ - "" - ] - }, - { - "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" ] @@ -70,6 +49,24 @@ "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",