mirror of
https://github.com/boostorg/container_hash.git
synced 2026-03-07 14:34:11 +01:00
Compare commits
57 Commits
boost-1.55
...
boost-1.59
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ada1369a14 | ||
|
|
4977373964 | ||
|
|
8b19e7eaa0 | ||
|
|
75ae18ef54 | ||
|
|
754d5f535e | ||
|
|
ebc607d44e | ||
|
|
549196ca7d | ||
|
|
f2761964bd | ||
|
|
41487a2e8c | ||
|
|
ca52df8a05 | ||
|
|
b39e6e96f0 | ||
|
|
8266a55b26 | ||
|
|
711b2b6d69 | ||
|
|
d888097468 | ||
|
|
23f1db7729 | ||
|
|
35ef2502d5 | ||
|
|
aa3ab0790a | ||
|
|
6c3e20ac18 | ||
|
|
97cc6fbbc1 | ||
|
|
309d17f387 | ||
|
|
928767f2bd | ||
|
|
bb2a91bf47 | ||
|
|
496bf24900 | ||
|
|
09f197abf6 | ||
|
|
582671543b | ||
|
|
6157ad5267 | ||
|
|
844d9758bd | ||
|
|
7dbc8b593f | ||
|
|
3c22fce14c | ||
|
|
b066a9c509 | ||
|
|
74603822f4 | ||
|
|
998f714f8f | ||
|
|
614feab582 | ||
|
|
999c2d5963 | ||
|
|
10c83e95d9 | ||
|
|
734eb87d2a | ||
|
|
af17fa46fb | ||
|
|
e26c102522 | ||
|
|
378007cf94 | ||
|
|
dea8d12a04 | ||
|
|
1870aa9534 | ||
|
|
0d6cee7e64 | ||
|
|
7d148af8d2 | ||
|
|
bb8ebafca1 | ||
|
|
7e162c4f03 | ||
|
|
061e0d9d6d | ||
|
|
e5f3356742 | ||
|
|
9721f9c764 | ||
|
|
8a8ab9ec70 | ||
|
|
13a86a7a26 | ||
|
|
0e0906b0a4 | ||
|
|
67ad8c2151 | ||
|
|
be4292842d | ||
|
|
473b1da8de | ||
|
|
8afae2e762 | ||
|
|
03380087a9 | ||
|
|
9dcc33ab1b |
@@ -168,5 +168,15 @@
|
||||
([ticket 8822]).
|
||||
* Suppress Visual C++ infinite loop warning ([ticket 8568]).
|
||||
|
||||
[h2 Boost 1.56.0]
|
||||
|
||||
* Removed some Visual C++ 6 workarounds.
|
||||
* Ongoing work on improving `hash_combine`. This changes the combine function
|
||||
which was previously defined in the reference documentation.
|
||||
|
||||
[h2 Boost 1.58.0]
|
||||
|
||||
* Fixed strict aliasing violation
|
||||
([@https://github.com/boostorg/functional/pull/3 GitHub #3]).
|
||||
|
||||
[endsect]
|
||||
|
||||
@@ -34,7 +34,7 @@ For other use cases, if you do need a higher quality hash function,
|
||||
then neither the standard hash function or `boost::hash` are appropriate.
|
||||
There are several options
|
||||
available. One is to use a second hash on the output of this hash
|
||||
function, such as [@http://www.concentric.net/~ttwang/tech/inthash.htm
|
||||
function, such as [@http://web.archive.org/web/20121102023700/http://www.concentric.net/~Ttwang/tech/inthash.htm
|
||||
Thomas Wang's hash function]. This this may not work as
|
||||
well as a hash algorithm tailored for the input.
|
||||
|
||||
|
||||
30
doc/ref.xml
30
doc/ref.xml
@@ -59,6 +59,11 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
Forward declared in
|
||||
<code><boost/functional/hash_fwd.hpp></code>
|
||||
</para>
|
||||
<para>
|
||||
This hash function is not intended for general use, and isn't
|
||||
guaranteed to be equal during separate runs of a program - so
|
||||
please don't use it for any persistent storage or communication.
|
||||
</para>
|
||||
</notes>
|
||||
<throws><para>
|
||||
Only throws if
|
||||
@@ -450,7 +455,15 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
Called repeatedly to incrementally create a hash value from
|
||||
several variables.
|
||||
</simpara></purpose>
|
||||
<effects><programlisting>seed ^= <functionname>hash_value</functionname>(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);</programlisting></effects>
|
||||
<effects>
|
||||
Updates <code>seed</code> with a new hash value generated by
|
||||
combining it with the result of
|
||||
<code><functionname>hash_value</functionname>(v)</code>. Will
|
||||
always produce the same result for the same combination of
|
||||
<code>seed</code> and
|
||||
<code><functionname>hash_value</functionname>(v)</code> during
|
||||
the single run of a program.
|
||||
</effects>
|
||||
<notes>
|
||||
<para><functionname>hash_value</functionname> is called without
|
||||
qualification, so that overloads can be found via ADL.</para>
|
||||
@@ -459,6 +472,11 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
Forward declared in
|
||||
<code><boost/functional/hash_fwd.hpp></code>
|
||||
</para>
|
||||
<para>
|
||||
This hash function is not intended for general use, and isn't
|
||||
guaranteed to be equal during separate runs of a program - so
|
||||
please don't use it for any persistent storage or communication.
|
||||
</para>
|
||||
</notes>
|
||||
<throws>
|
||||
Only throws if <functionname>hash_value</functionname>(T) throws.
|
||||
@@ -527,6 +545,11 @@ for(; first != last; ++first)
|
||||
Forward declared in
|
||||
<code><boost/functional/hash_fwd.hpp></code>
|
||||
</para>
|
||||
<para>
|
||||
This hash function is not intended for general use, and isn't
|
||||
guaranteed to be equal during separate runs of a program - so
|
||||
please don't use it for any persistent storage or communication.
|
||||
</para>
|
||||
</notes>
|
||||
<throws><para>
|
||||
Only throws if <code><functionname>hash_value</functionname>(std::iterator_traits<It>::value_type)</code>
|
||||
@@ -784,6 +807,11 @@ for(; first != last; ++first)
|
||||
|
||||
<notes>
|
||||
<para>This is an extension to TR1</para>
|
||||
<para>
|
||||
This hash function is not intended for general use, and isn't
|
||||
guaranteed to be equal during separate runs of a program - so
|
||||
please don't use it for any persistent storage or communication.
|
||||
</para>
|
||||
</notes>
|
||||
|
||||
<throws>
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
#define BOOST_FUNCTIONAL_HASH_DETAIL_FLOAT_FUNCTIONS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config/no_tr1/cmath.hpp>
|
||||
|
||||
// Set BOOST_HASH_CONFORMANT_FLOATS to 1 for libraries known to have
|
||||
// sufficiently good floating point support to not require any
|
||||
// workarounds.
|
||||
|
||||
@@ -6,11 +6,11 @@
|
||||
#if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER)
|
||||
#define BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/functional/hash/detail/float_functions.hpp>
|
||||
#include <boost/functional/hash/detail/limits.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
@@ -68,7 +68,7 @@ namespace boost
|
||||
std::size_t seed = 0;
|
||||
|
||||
if (length >= sizeof(std::size_t)) {
|
||||
seed = *(std::size_t*) ptr;
|
||||
std::memcpy(&seed, ptr, sizeof(std::size_t));
|
||||
length -= sizeof(std::size_t);
|
||||
ptr += sizeof(std::size_t);
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
#if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER)
|
||||
#define BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/limits.hpp>
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
#if !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP)
|
||||
#define BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/functional/hash/hash.hpp>
|
||||
#include <boost/detail/container_fwd.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
@@ -32,18 +37,10 @@
|
||||
# include <memory>
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
||||
#include <boost/type_traits/is_array.hpp>
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
template <class A, class B>
|
||||
@@ -232,11 +229,7 @@ namespace boost
|
||||
template <class Array>
|
||||
struct inner
|
||||
{
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
static std::size_t call(Array const& v)
|
||||
#else
|
||||
static std::size_t call(Array& v)
|
||||
#endif
|
||||
{
|
||||
const int size = sizeof(v) / sizeof(*v);
|
||||
return boost::hash_range(v, v + size);
|
||||
@@ -298,8 +291,6 @@ namespace boost
|
||||
template <bool IsPointer>
|
||||
struct hash_impl;
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
|
||||
template <>
|
||||
struct hash_impl<false>
|
||||
{
|
||||
@@ -320,58 +311,6 @@ namespace boost
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
#else // Visual C++ 6.5
|
||||
|
||||
// Visual C++ 6.5 has problems with nested member functions and
|
||||
// applying const to const types in templates. So we get this:
|
||||
|
||||
template <bool IsConst>
|
||||
struct hash_impl_msvc
|
||||
{
|
||||
template <class T>
|
||||
struct inner
|
||||
: public std::unary_function<T, std::size_t>
|
||||
{
|
||||
std::size_t operator()(T const& val) const
|
||||
{
|
||||
return hash_detail::call_hash<T const>::call(val);
|
||||
}
|
||||
|
||||
std::size_t operator()(T& val) const
|
||||
{
|
||||
return hash_detail::call_hash<T>::call(val);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <>
|
||||
struct hash_impl_msvc<true>
|
||||
{
|
||||
template <class T>
|
||||
struct inner
|
||||
: public std::unary_function<T, std::size_t>
|
||||
{
|
||||
std::size_t operator()(T& val) const
|
||||
{
|
||||
return hash_detail::call_hash<T>::call(val);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct hash_impl_msvc2
|
||||
: public hash_impl_msvc<boost::is_const<T>::value>
|
||||
::BOOST_NESTED_TEMPLATE inner<T> {};
|
||||
|
||||
template <>
|
||||
struct hash_impl<false>
|
||||
{
|
||||
template <class T>
|
||||
struct inner : public hash_impl_msvc2<T> {};
|
||||
};
|
||||
|
||||
#endif // Visual C++ 6.5
|
||||
}
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
}
|
||||
|
||||
@@ -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 <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/utility/enable_if.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||
#include <boost/type_traits/is_pointer.hpp>
|
||||
@@ -29,11 +36,15 @@
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(push)
|
||||
|
||||
#if BOOST_MSVC >= 1400
|
||||
#pragma warning(disable:6295) // Ill-defined for-loop : 'unsigned int' values
|
||||
// are always of range '0' to '4294967295'.
|
||||
// Loop executes infinitely.
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(__GNUC__, < 3) \
|
||||
&& !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
||||
#define BOOST_HASH_CHAR_TRAITS string_char_traits
|
||||
@@ -41,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
|
||||
@@ -188,6 +205,51 @@ namespace boost
|
||||
|
||||
return seed;
|
||||
}
|
||||
|
||||
template <typename SizeT>
|
||||
inline void hash_combine_impl(SizeT& seed, SizeT value)
|
||||
{
|
||||
seed ^= value + 0x9e3779b9 + (seed<<6) + (seed>>2);
|
||||
}
|
||||
|
||||
template <typename SizeT>
|
||||
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 <typename SizeT>
|
||||
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 <typename T>
|
||||
@@ -244,16 +306,11 @@ namespace boost
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
template <class T>
|
||||
inline void hash_combine(std::size_t& seed, T& v)
|
||||
#else
|
||||
template <class T>
|
||||
inline void hash_combine(std::size_t& seed, T const& v)
|
||||
#endif
|
||||
{
|
||||
boost::hash<T> hasher;
|
||||
seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
|
||||
return boost::hash_detail::hash_combine_impl(seed, hasher(v));
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
@@ -358,7 +415,6 @@ namespace boost
|
||||
//
|
||||
// These are undefined later.
|
||||
|
||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
#define BOOST_HASH_SPECIALIZE(type) \
|
||||
template <> struct hash<type> \
|
||||
: public std::unary_function<type, std::size_t> \
|
||||
@@ -378,45 +434,6 @@ namespace boost
|
||||
return boost::hash_value(v); \
|
||||
} \
|
||||
};
|
||||
#else
|
||||
#define BOOST_HASH_SPECIALIZE(type) \
|
||||
template <> struct hash<type> \
|
||||
: public std::unary_function<type, std::size_t> \
|
||||
{ \
|
||||
std::size_t operator()(type v) const \
|
||||
{ \
|
||||
return boost::hash_value(v); \
|
||||
} \
|
||||
}; \
|
||||
\
|
||||
template <> struct hash<const type> \
|
||||
: public std::unary_function<const type, std::size_t> \
|
||||
{ \
|
||||
std::size_t operator()(const type v) const \
|
||||
{ \
|
||||
return boost::hash_value(v); \
|
||||
} \
|
||||
};
|
||||
|
||||
#define BOOST_HASH_SPECIALIZE_REF(type) \
|
||||
template <> struct hash<type> \
|
||||
: public std::unary_function<type, std::size_t> \
|
||||
{ \
|
||||
std::size_t operator()(type const& v) const \
|
||||
{ \
|
||||
return boost::hash_value(v); \
|
||||
} \
|
||||
}; \
|
||||
\
|
||||
template <> struct hash<const type> \
|
||||
: public std::unary_function<const type, std::size_t> \
|
||||
{ \
|
||||
std::size_t operator()(type const& v) const \
|
||||
{ \
|
||||
return boost::hash_value(v); \
|
||||
} \
|
||||
};
|
||||
#endif
|
||||
|
||||
BOOST_HASH_SPECIALIZE(bool)
|
||||
BOOST_HASH_SPECIALIZE(char)
|
||||
@@ -524,6 +541,7 @@ namespace boost
|
||||
}
|
||||
|
||||
#undef BOOST_HASH_CHAR_TRAITS
|
||||
#undef BOOST_FUNCTIONAL_HASH_ROTL32
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
#pragma warning(pop)
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#if !defined(BOOST_FUNCTIONAL_HASH_FWD_HPP)
|
||||
#define BOOST_FUNCTIONAL_HASH_FWD_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
||||
# pragma once
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/detail/workaround.hpp>
|
||||
|
||||
@@ -22,11 +22,7 @@ namespace boost
|
||||
{
|
||||
template <class T> struct hash;
|
||||
|
||||
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||
template <class T> void hash_combine(std::size_t& seed, T& v);
|
||||
#else
|
||||
template <class T> void hash_combine(std::size_t& seed, T const& v);
|
||||
#endif
|
||||
|
||||
template <class It> std::size_t hash_range(It, It);
|
||||
template <class It> void hash_range(std::size_t&, It, It);
|
||||
|
||||
@@ -3,5 +3,9 @@
|
||||
// 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)
|
||||
|
||||
#include <boost/functional/hash/hash_fwd.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#if defined(BOOST_HAS_PRAGMA_ONCE)
|
||||
#pragma once
|
||||
#endif
|
||||
|
||||
#include <boost/functional/hash/hash_fwd.hpp>
|
||||
|
||||
20
meta/libraries.json
Normal file
20
meta/libraries.json
Normal file
@@ -0,0 +1,20 @@
|
||||
[
|
||||
{
|
||||
"key": "functional/hash",
|
||||
"boost-version": "1.33.0",
|
||||
"name": "Functional/Hash",
|
||||
"authors": [
|
||||
"Daniel James"
|
||||
],
|
||||
"maintainers": [
|
||||
"Daniel James <dnljms -at- gmail.com>"
|
||||
],
|
||||
"description": "A TR1 hash function object that can be extended to hash user defined types.",
|
||||
"std": [
|
||||
"tr1"
|
||||
],
|
||||
"category": [
|
||||
"Function-objects"
|
||||
]
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user