mirror of
https://github.com/boostorg/functional.git
synced 2025-08-03 22:44:31 +02:00
Copy hash library from 1.34.1 over trunk.
For the first merge with the release branch, I only want to include some of the changes I've been working on (fixes and some trivial changes), so I'm starting again from 1.34.1. [SVN r38873]
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
# Copyright 2005 Daniel James.
|
# Copyright Daniel James 2005. Use, modification, and distribution are
|
||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# subject to 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
using quickbook ;
|
using quickbook ;
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
[/ Copyright 2005-2007 Daniel James.
|
[/ Copyright 2005-2006 Daniel James.
|
||||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
/ 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) ]
|
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ]
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
[/ Copyright 2005-2007 Daniel James.
|
[/ Copyright 2005-2006 Daniel James.
|
||||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
/ 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) ]
|
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ]
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
[library Boost.Functional/Hash
|
[library Boost.Functional/Hash
|
||||||
[quickbook 1.3]
|
[quickbook 1.3]
|
||||||
[authors [James, Daniel]]
|
[authors [James, Daniel]]
|
||||||
[copyright 2005 2007 Daniel James]
|
[copyright 2005 2006 Daniel James]
|
||||||
[purpose A TR1 hash function object that can be extended to hash user
|
[purpose A TR1 hash function object that can be extended to hash user
|
||||||
defined types]
|
defined types]
|
||||||
[category higher-order]
|
[category higher-order]
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
[license
|
[license
|
||||||
Distributed under the Boost Software License, Version 1.0.
|
Distributed under the Boost Software License, Version 1.0.
|
||||||
(See accompanying file LICENSE_1_0.txt or copy at
|
(See accompanying file LICENSE_1_0.txt or copy at
|
||||||
[@http://www.boost.org/LICENSE_1_0.txt])
|
[@http://www.boost.org/LICENSE_1_0.txt]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
[/ Copyright 2005-2007 Daniel James.
|
[/ Copyright 2005-2006 Daniel James.
|
||||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
/ 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) ]
|
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ]
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
[/ Copyright 2005-2007 Daniel James.
|
[/ Copyright 2005-2006 Daniel James.
|
||||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
/ 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) ]
|
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ]
|
||||||
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
[/ Copyright 2005-2007 Daniel James.
|
[/ Copyright 2005-2006 Daniel James.
|
||||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
/ 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) ]
|
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ]
|
||||||
|
|
||||||
|
105
hash/doc/ref.xml
105
hash/doc/ref.xml
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Copyright Daniel James 2005-2007
|
Copyright 2005-2006 Daniel James.
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
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)
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
-->
|
-->
|
||||||
@@ -261,42 +260,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|||||||
</method>
|
</method>
|
||||||
</struct-specialization>
|
</struct-specialization>
|
||||||
|
|
||||||
<struct-specialization name="hash">
|
|
||||||
<template></template>
|
|
||||||
<specialization>
|
|
||||||
<template-arg>long long</template-arg>
|
|
||||||
</specialization>
|
|
||||||
<method name="operator()" cv="const">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
<parameter name="val">
|
|
||||||
<paramtype>long long</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<returns>
|
|
||||||
<para>Unspecified in TR1, except that equal arguments yield the same result.</para>
|
|
||||||
<para><functionname>hash_value</functionname>(val) in Boost.</para>
|
|
||||||
</returns>
|
|
||||||
<throws><para>Doesn't throw</para></throws>
|
|
||||||
</method>
|
|
||||||
</struct-specialization>
|
|
||||||
|
|
||||||
<struct-specialization name="hash">
|
|
||||||
<template></template>
|
|
||||||
<specialization>
|
|
||||||
<template-arg>unsigned long long</template-arg>
|
|
||||||
</specialization>
|
|
||||||
<method name="operator()" cv="const">
|
|
||||||
<type>std::size_t</type>
|
|
||||||
<parameter name="val">
|
|
||||||
<paramtype>unsigned long long</paramtype>
|
|
||||||
</parameter>
|
|
||||||
<returns>
|
|
||||||
<para>Unspecified in TR1, except that equal arguments yield the same result.</para>
|
|
||||||
<para><functionname>hash_value</functionname>(val) in Boost.</para>
|
|
||||||
</returns>
|
|
||||||
<throws><para>Doesn't throw</para></throws>
|
|
||||||
</method>
|
|
||||||
</struct-specialization>
|
|
||||||
|
|
||||||
<struct-specialization name="hash">
|
<struct-specialization name="hash">
|
||||||
<template></template>
|
<template></template>
|
||||||
<specialization>
|
<specialization>
|
||||||
@@ -406,8 +369,6 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|||||||
</method>
|
</method>
|
||||||
</struct-specialization>
|
</struct-specialization>
|
||||||
|
|
||||||
<free-function-group name="Support functions (Boost extension).">
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
boost::hash_combine
|
boost::hash_combine
|
||||||
-->
|
-->
|
||||||
@@ -502,10 +463,6 @@ for(; first != last; ++first)
|
|||||||
</para></throws>
|
</para></throws>
|
||||||
</overloaded-function>
|
</overloaded-function>
|
||||||
|
|
||||||
</free-function-group>
|
|
||||||
|
|
||||||
<free-function-group name="Overloadable hash implementation (Boost extension).">
|
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
boost::hash_value - integers
|
boost::hash_value - integers
|
||||||
-->
|
-->
|
||||||
@@ -515,36 +472,6 @@ for(; first != last; ++first)
|
|||||||
Implementation of the hash function.
|
Implementation of the hash function.
|
||||||
</purpose>
|
</purpose>
|
||||||
|
|
||||||
<signature>
|
|
||||||
<type>std::size_t</type>
|
|
||||||
<parameter name="val"><paramtype>bool</paramtype></parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<signature>
|
|
||||||
<type>std::size_t</type>
|
|
||||||
<parameter name="val"><paramtype>char</paramtype></parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<signature>
|
|
||||||
<type>std::size_t</type>
|
|
||||||
<parameter name="val"><paramtype>signed char</paramtype></parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<signature>
|
|
||||||
<type>std::size_t</type>
|
|
||||||
<parameter name="val"><paramtype>unsigned char</paramtype></parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<signature>
|
|
||||||
<type>std::size_t</type>
|
|
||||||
<parameter name="val"><paramtype>short</paramtype></parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<signature>
|
|
||||||
<type>std::size_t</type>
|
|
||||||
<parameter name="val"><paramtype>unsigned short</paramtype></parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<signature>
|
<signature>
|
||||||
<type>std::size_t</type>
|
<type>std::size_t</type>
|
||||||
<parameter name="val"><paramtype>int</paramtype></parameter>
|
<parameter name="val"><paramtype>int</paramtype></parameter>
|
||||||
@@ -565,16 +492,6 @@ for(; first != last; ++first)
|
|||||||
<parameter name="val"><paramtype>unsigned long</paramtype></parameter>
|
<parameter name="val"><paramtype>unsigned long</paramtype></parameter>
|
||||||
</signature>
|
</signature>
|
||||||
|
|
||||||
<signature>
|
|
||||||
<type>std::size_t</type>
|
|
||||||
<parameter name="val"><paramtype>long long</paramtype></parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<signature>
|
|
||||||
<type>std::size_t</type>
|
|
||||||
<parameter name="val"><paramtype>unsigned long long</paramtype></parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<signature>
|
<signature>
|
||||||
<type>std::size_t</type>
|
<type>std::size_t</type>
|
||||||
<parameter name="val"><paramtype>float</paramtype></parameter>
|
<parameter name="val"><paramtype>float</paramtype></parameter>
|
||||||
@@ -703,14 +620,6 @@ for(; first != last; ++first)
|
|||||||
<parameter name="val"><paramtype>std::multimap<K, T, C, A> const&</paramtype></parameter>
|
<parameter name="val"><paramtype>std::multimap<K, T, C, A> const&</paramtype></parameter>
|
||||||
</signature>
|
</signature>
|
||||||
|
|
||||||
<signature>
|
|
||||||
<template>
|
|
||||||
<template-type-parameter name="T"/>
|
|
||||||
</template>
|
|
||||||
<type>std::size_t</type>
|
|
||||||
<parameter name="val"><paramtype>std::complex<T> const&</paramtype></parameter>
|
|
||||||
</signature>
|
|
||||||
|
|
||||||
<description><para>
|
<description><para>
|
||||||
Generally shouldn't be called directly by users, instead they should use
|
Generally shouldn't be called directly by users, instead they should use
|
||||||
<classname>boost::hash</classname>, <functionname>boost::hash_range</functionname>
|
<classname>boost::hash</classname>, <functionname>boost::hash_range</functionname>
|
||||||
@@ -744,10 +653,6 @@ for(; first != last; ++first)
|
|||||||
<entry><code>int</code>, <code>unsigned int</code>, <code>long</code>, <code>unsigned long</code></entry>
|
<entry><code>int</code>, <code>unsigned int</code>, <code>long</code>, <code>unsigned long</code></entry>
|
||||||
<entry><code>val</code></entry>
|
<entry><code>val</code></entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
|
||||||
<entry><code>long long</code>, <code>unsigned long long</code></entry>
|
|
||||||
<entry><code>val</code> when <code>abs(val) <= std::numeric_limits<std::size_t>::max()</code>.</entry>
|
|
||||||
</row>
|
|
||||||
<row>
|
<row>
|
||||||
<entry><code>float</code>, <code>double</code>, <code>long double</code></entry>
|
<entry><code>float</code>, <code>double</code>, <code>long double</code></entry>
|
||||||
<entry>An unspecified value, except that equal arguments shall yield the same result.</entry>
|
<entry>An unspecified value, except that equal arguments shall yield the same result.</entry>
|
||||||
@@ -783,19 +688,11 @@ for(; first != last; ++first)
|
|||||||
<functionname>hash_combine</functionname>(seed, val.second);
|
<functionname>hash_combine</functionname>(seed, val.second);
|
||||||
return seed;</programlisting></entry>
|
return seed;</programlisting></entry>
|
||||||
</row>
|
</row>
|
||||||
<row>
|
|
||||||
<entry>
|
|
||||||
<code>std::complex<val[N]></code>
|
|
||||||
</entry>
|
|
||||||
<entry>For built in types when <code>val.imag() == 0</code>, <code>hash_value(val.real())</code></entry>
|
|
||||||
</row>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</tgroup>
|
</tgroup>
|
||||||
</informaltable>
|
</informaltable>
|
||||||
</returns>
|
</returns>
|
||||||
</overloaded-function>
|
</overloaded-function>
|
||||||
|
|
||||||
</free-function-group>
|
|
||||||
</namespace>
|
</namespace>
|
||||||
</header>
|
</header>
|
||||||
</library-reference>
|
</library-reference>
|
||||||
|
@@ -1,19 +1,20 @@
|
|||||||
|
|
||||||
[/ Copyright 2005-2007 Daniel James.
|
[/ Copyright 2005-2006 Daniel James.
|
||||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
/ 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) ]
|
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ]
|
||||||
|
|
||||||
[section:acknowledgements Acknowledgements]
|
[section:acknowledgements Acknowledgements]
|
||||||
|
|
||||||
This library is based on the design by Peter Dimov. During the initial
|
This library is based on the design by Peter Dimov's original design.
|
||||||
development
|
|
||||||
Joaquín M López Muñoz made many useful suggestions and contributed fixes.
|
During the initial development Joaquín M López Muñoz made many useful
|
||||||
|
suggestions, contributed fixes.
|
||||||
|
|
||||||
The formal review was managed by Thorsten Ottosen, and the library reviewed by:
|
The formal review was managed by Thorsten Ottosen, and the library reviewed by:
|
||||||
David Abrahams, Alberto Barbati, Topher Cooper, Caleb Epstein, Dave Harris,
|
David Abrahams, Alberto Barbati, Topher Cooper, Caleb Epstein, Dave Harris,
|
||||||
Chris Jefferson, Bronek Kozicki, John Maddock, Tobias Swinger, Jaap Suter,
|
Chris Jefferson, Bronek Kozicki, John Maddock, Tobias Swinger, Jaap Suter, Rob
|
||||||
Rob Stewart and Pavel Vozenilek. Since then, further constructive criticism has
|
Stewart and Pavel Vozenilek. Since then, there have been further contributions
|
||||||
been made by Daniel Krügler, Alexander Nasonov and 沈慧峰.
|
from Daniel Krügler, Alexander Nasonov, 沈慧峰 and John Maddock.
|
||||||
|
|
||||||
The implementation of the hash function for pointers is based on suggestions
|
The implementation of the hash function for pointers is based on suggestions
|
||||||
made by Alberto Barbati and Dave Harris. Dave Harris also suggested an
|
made by Alberto Barbati and Dave Harris. Dave Harris also suggested an
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
[/ Copyright 2005-2007 Daniel James.
|
[/ Copyright 2005-2006 Daniel James.
|
||||||
/ Distributed under the Boost Software License, Version 1.0. (See accompanying
|
/ 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) ]
|
/ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ]
|
||||||
|
|
||||||
@@ -119,7 +119,7 @@ When writing a hash function, first look at how the equality function works.
|
|||||||
Objects that are equal must generate the same hash value.
|
Objects that are equal must generate the same hash value.
|
||||||
When objects are not equal they should generate different hash values.
|
When objects are not equal they should generate different hash values.
|
||||||
In this object equality was based just on the id so the hash function
|
In this object equality was based just on the id so the hash function
|
||||||
only hashes the id. If it was based on the object's name and author
|
only hash the id. If it was based on the objects name and author
|
||||||
then the hash function should take them into account
|
then the hash function should take them into account
|
||||||
(how to do this is discussed in the next section).
|
(how to do this is discussed in the next section).
|
||||||
]
|
]
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./books.hpp"
|
#include "./books.hpp"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// This example illustrates how to use boost::hash with a custom hash function.
|
// This example illustrates how to use boost::hash with a custom hash function.
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005 Daniel James.
|
// Copyright Daniel James 2005. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
<!--
|
<!--
|
||||||
Copyright 2005-2007 Daniel James.
|
Copyright 2005-2006 Daniel James.
|
||||||
Distributed under the Boost Software License, Version 1.0. (See accompanying
|
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)
|
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
-->
|
-->
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
# Copyright 2005-2007 Daniel James.
|
# Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
# Distributed under the Boost Software License, Version 1.0. (See accompanying
|
# subject to 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)
|
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
import testing ;
|
import testing ;
|
||||||
@@ -8,8 +8,6 @@ import testing ;
|
|||||||
project hash-tests
|
project hash-tests
|
||||||
: requirements
|
: requirements
|
||||||
<toolset>gcc:<define>_GLIBCXX_DEBUG
|
<toolset>gcc:<define>_GLIBCXX_DEBUG
|
||||||
"<toolset>gcc:<cxxflags>-Wsign-promo -Wextra"
|
|
||||||
<toolset>msvc:<cxxflags>/W4
|
|
||||||
;
|
;
|
||||||
|
|
||||||
test-suite functional/hash
|
test-suite functional/hash
|
||||||
@@ -32,7 +30,6 @@ test-suite functional/hash
|
|||||||
[ run hash_deque_test.cpp ]
|
[ run hash_deque_test.cpp ]
|
||||||
[ run hash_set_test.cpp ]
|
[ run hash_set_test.cpp ]
|
||||||
[ run hash_map_test.cpp ]
|
[ run hash_map_test.cpp ]
|
||||||
[ run hash_complex_test.cpp ]
|
|
||||||
[ run link_test.cpp link_test_2.cpp ]
|
[ run link_test.cpp link_test_2.cpp ]
|
||||||
[ run link_ext_test.cpp link_no_ext_test.cpp ]
|
[ run link_ext_test.cpp link_no_ext_test.cpp ]
|
||||||
[ run container_fwd_test.cpp ]
|
[ run container_fwd_test.cpp ]
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
@@ -12,5 +12,5 @@ void compile_time_tests(T*)
|
|||||||
{
|
{
|
||||||
BOOST_STATIC_ASSERT((boost::is_base_and_derived<
|
BOOST_STATIC_ASSERT((boost::is_base_and_derived<
|
||||||
std::unary_function<T, std::size_t>, HASH_NAMESPACE::hash<T> >::value));
|
std::unary_function<T, std::size_t>, HASH_NAMESPACE::hash<T> >::value));
|
||||||
}
|
};
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#if defined(TEST_STD)
|
#if defined(TEST_STD)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/functional/detail/container_fwd.hpp>
|
#include <boost/functional/detail/container_fwd.hpp>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
@@ -18,23 +18,18 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable:4127) // conditional expression is constant
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void float_tests(char const* name, T* = 0)
|
void float_tests(char const* name, T* = 0)
|
||||||
{
|
{
|
||||||
std::cerr<<"\n"
|
std::cerr<<"\n"
|
||||||
<<"Testing " BOOST_STRINGIZE(HASH_NAMESPACE) "::hash<"<<name<<">\n"
|
<<"Testing " BOOST_STRINGIZE(HASH_NAMESPACE) "::hash<"<<name<<">\n"
|
||||||
<<"\n"
|
<<"\n"
|
||||||
<<"boost::hash_detail::limits<T>::digits = "
|
<<"std::numeric_limits<T>::digits = "
|
||||||
<<boost::hash_detail::limits<T>::digits<<"\n"
|
<<std::numeric_limits<T>::digits<<"\n"
|
||||||
<<"boost::hash_detail::limits<int>::digits = "
|
<<"std::numeric_limits<int>::digits = "
|
||||||
<<boost::hash_detail::limits<int>::digits<<"\n"
|
<<std::numeric_limits<int>::digits<<"\n"
|
||||||
<<"boost::hash_detail::limits<std::size_t>::digits = "
|
<<"std::numeric_limits<std::size_t>::digits = "
|
||||||
<<boost::hash_detail::limits<std::size_t>::digits<<"\n"
|
<<std::numeric_limits<std::size_t>::digits<<"\n"
|
||||||
<<"\n"
|
<<"\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -55,11 +50,11 @@ void float_tests(char const* name, T* = 0)
|
|||||||
#if defined(__BORLANDC__)
|
#if defined(__BORLANDC__)
|
||||||
std::cerr<<"Not running infinity checks on Borland, as it causes it to crash.\n";
|
std::cerr<<"Not running infinity checks on Borland, as it causes it to crash.\n";
|
||||||
#else
|
#else
|
||||||
if(boost::hash_detail::limits<T>::has_infinity) {
|
if(std::numeric_limits<T>::has_infinity) {
|
||||||
T infinity = -log(zero);
|
T infinity = -log(zero);
|
||||||
T infinity2 = (T) 1. / zero;
|
T infinity2 = (T) 1. / zero;
|
||||||
T infinity3 = (T) -1. / minus_zero;
|
T infinity3 = (T) -1. / minus_zero;
|
||||||
T infinity4 = boost::hash_detail::limits<T>::infinity();
|
T infinity4 = std::numeric_limits<T>::infinity();
|
||||||
|
|
||||||
T minus_infinity = log(zero);
|
T minus_infinity = log(zero);
|
||||||
T minus_infinity2 = (T) -1. / zero;
|
T minus_infinity2 = (T) -1. / zero;
|
||||||
@@ -71,7 +66,7 @@ void float_tests(char const* name, T* = 0)
|
|||||||
|
|
||||||
if(infinity == infinity2)
|
if(infinity == infinity2)
|
||||||
BOOST_TEST(x1(infinity) == x1(infinity2));
|
BOOST_TEST(x1(infinity) == x1(infinity2));
|
||||||
if(infinity == infinity3)
|
if(infinity == infinity3);
|
||||||
BOOST_TEST(x1(infinity) == x1(infinity3));
|
BOOST_TEST(x1(infinity) == x1(infinity3));
|
||||||
if(infinity == infinity4)
|
if(infinity == infinity4)
|
||||||
BOOST_TEST(x1(infinity) == x1(infinity4));
|
BOOST_TEST(x1(infinity) == x1(infinity4));
|
||||||
@@ -89,26 +84,26 @@ void float_tests(char const* name, T* = 0)
|
|||||||
|
|
||||||
// This should really be 'has_denorm == denorm_present' but some
|
// This should really be 'has_denorm == denorm_present' but some
|
||||||
// compilers don't have 'denorm_present'. See also a later use.
|
// compilers don't have 'denorm_present'. See also a later use.
|
||||||
if(boost::hash_detail::limits<T>::has_denorm) {
|
if(std::numeric_limits<T>::has_denorm) {
|
||||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) == x1(infinity)) {
|
if(x1(std::numeric_limits<T>::denorm_min()) == x1(infinity)) {
|
||||||
std::cerr<<"x1(denorm_min) == x1(infinity) == "<<x1(infinity)<<"\n";
|
std::cerr<<"x1(denorm_min) == x1(infinity) == "<<x1(infinity)<<"\n";
|
||||||
}
|
}
|
||||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) == x1(minus_infinity)) {
|
if(x1(std::numeric_limits<T>::denorm_min()) == x1(minus_infinity)) {
|
||||||
std::cerr<<"x1(denorm_min) == x1(-infinity) == "<<x1(minus_infinity)<<"\n";
|
std::cerr<<"x1(denorm_min) == x1(-infinity) == "<<x1(minus_infinity)<<"\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(boost::hash_detail::limits<T>::has_quiet_NaN) {
|
if(std::numeric_limits<T>::has_quiet_NaN) {
|
||||||
if(x1(boost::hash_detail::limits<T>::quiet_NaN()) == x1(infinity)) {
|
if(x1(std::numeric_limits<T>::quiet_NaN()) == x1(infinity)) {
|
||||||
std::cerr<<"x1(quiet_NaN) == x1(infinity) == "<<x1(infinity)<<"\n";
|
std::cerr<<"x1(quiet_NaN) == x1(infinity) == "<<x1(infinity)<<"\n";
|
||||||
}
|
}
|
||||||
if(x1(boost::hash_detail::limits<T>::quiet_NaN()) == x1(minus_infinity)) {
|
if(x1(std::numeric_limits<T>::quiet_NaN()) == x1(minus_infinity)) {
|
||||||
std::cerr<<"x1(quiet_NaN) == x1(-infinity) == "<<x1(minus_infinity)<<"\n";
|
std::cerr<<"x1(quiet_NaN) == x1(-infinity) == "<<x1(minus_infinity)<<"\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
T max = (boost::hash_detail::limits<T>::max)();
|
T max = (std::numeric_limits<T>::max)();
|
||||||
T half_max = max / 2;
|
T half_max = max / 2;
|
||||||
T quarter_max = max / 4;
|
T quarter_max = max / 4;
|
||||||
T three_quarter_max = max - quarter_max;
|
T three_quarter_max = max - quarter_max;
|
||||||
@@ -142,50 +137,50 @@ void float_tests(char const* name, T* = 0)
|
|||||||
BOOST_TEST(x1(v2) == HASH_NAMESPACE::hash_value(v2));
|
BOOST_TEST(x1(v2) == HASH_NAMESPACE::hash_value(v2));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BOOST_TEST(x1(boost::hash_detail::limits<T>::epsilon()) ==
|
BOOST_TEST(x1(std::numeric_limits<T>::epsilon()) ==
|
||||||
HASH_NAMESPACE::hash_value(boost::hash_detail::limits<T>::epsilon()));
|
HASH_NAMESPACE::hash_value(std::numeric_limits<T>::epsilon()));
|
||||||
|
|
||||||
BOOST_TEST(boost::hash_detail::limits<T>::epsilon() != (T) 0);
|
BOOST_TEST(std::numeric_limits<T>::epsilon() != (T) 0);
|
||||||
if(x1(boost::hash_detail::limits<T>::epsilon()) == x1((T) 0))
|
if(x1(std::numeric_limits<T>::epsilon()) == x1((T) 0))
|
||||||
std::cerr<<"x1(epsilon) == x1(0) == "<<x1((T) 0)<<"\n";
|
std::cerr<<"x1(epsilon) == x1(0) == "<<x1((T) 0)<<"\n";
|
||||||
|
|
||||||
BOOST_TEST(-boost::hash_detail::limits<T>::epsilon() != (T) 0);
|
BOOST_TEST(-std::numeric_limits<T>::epsilon() != (T) 0);
|
||||||
if(x1(-boost::hash_detail::limits<T>::epsilon()) == x1((T) 0))
|
if(x1(-std::numeric_limits<T>::epsilon()) == x1((T) 0))
|
||||||
std::cerr<<"x1(-epsilon) == x1(0) == "<<x1((T) 0)<<"\n";
|
std::cerr<<"x1(-epsilon) == x1(0) == "<<x1((T) 0)<<"\n";
|
||||||
|
|
||||||
BOOST_TEST((T) 1 + boost::hash_detail::limits<T>::epsilon() != (T) 1);
|
BOOST_TEST((T) 1 + std::numeric_limits<T>::epsilon() != (T) 1);
|
||||||
if(x1((T) 1 + boost::hash_detail::limits<T>::epsilon()) == x1((T) 1))
|
if(x1((T) 1 + std::numeric_limits<T>::epsilon()) == x1((T) 1))
|
||||||
std::cerr<<"x1(1 + epsilon) == x1(1) == "<<x1((T) 1)<<"\n";
|
std::cerr<<"x1(1 + epsilon) == x1(1) == "<<x1((T) 1)<<"\n";
|
||||||
|
|
||||||
BOOST_TEST((T) 1 - boost::hash_detail::limits<T>::epsilon() != (T) 1);
|
BOOST_TEST((T) 1 - std::numeric_limits<T>::epsilon() != (T) 1);
|
||||||
if(x1((T) 1 - boost::hash_detail::limits<T>::epsilon()) == x1((T) 1))
|
if(x1((T) 1 - std::numeric_limits<T>::epsilon()) == x1((T) 1))
|
||||||
std::cerr<<"x1(1 - epsilon) == x1(1) == "<<x1((T) 1)<<"\n";
|
std::cerr<<"x1(1 - epsilon) == x1(1) == "<<x1((T) 1)<<"\n";
|
||||||
|
|
||||||
BOOST_TEST((T) -1 + boost::hash_detail::limits<T>::epsilon() != (T) -1);
|
BOOST_TEST((T) -1 + std::numeric_limits<T>::epsilon() != (T) -1);
|
||||||
if(x1((T) -1 + boost::hash_detail::limits<T>::epsilon()) == x1((T) -1))
|
if(x1((T) -1 + std::numeric_limits<T>::epsilon()) == x1((T) -1))
|
||||||
std::cerr<<"x1(-1 + epsilon) == x1(-1) == "<<x1((T) -1)<<"\n";
|
std::cerr<<"x1(-1 + epsilon) == x1(-1) == "<<x1((T) -1)<<"\n";
|
||||||
|
|
||||||
BOOST_TEST((T) -1 - boost::hash_detail::limits<T>::epsilon() != (T) -1);
|
BOOST_TEST((T) -1 - std::numeric_limits<T>::epsilon() != (T) -1);
|
||||||
if(x1((T) -1 - boost::hash_detail::limits<T>::epsilon()) == x1((T) -1))
|
if(x1((T) -1 - std::numeric_limits<T>::epsilon()) == x1((T) -1))
|
||||||
std::cerr<<"x1(-1 - epsilon) == x1(-1) == "<<x1((T) -1)<<"\n";
|
std::cerr<<"x1(-1 - epsilon) == x1(-1) == "<<x1((T) -1)<<"\n";
|
||||||
|
|
||||||
// As before.
|
// As before.
|
||||||
if(boost::hash_detail::limits<T>::has_denorm) {
|
if(std::numeric_limits<T>::has_denorm) {
|
||||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) == x1(zero)) {
|
if(x1(std::numeric_limits<T>::denorm_min()) == x1(zero)) {
|
||||||
std::cerr<<"x1(denorm_min) == x1(zero) == "<<x1(zero)<<"\n";
|
std::cerr<<"x1(denorm_min) == x1(zero) == "<<x1(zero)<<"\n";
|
||||||
}
|
}
|
||||||
#if !BOOST_WORKAROUND(__DECCXX_VER,<70190006)
|
#if !BOOST_WORKAROUND(__DECCXX_VER,<70190006)
|
||||||
// The Tru64/CXX standard library prior to 7.1 contains a bug in the
|
// The Tru64/CXX standard library prior to 7.1 contains a bug in the
|
||||||
// specialization of boost::hash_detail::limits::denorm_min() for long
|
// specialization of std::numeric_limits::denorm_min() for long
|
||||||
// doubles which causes this test to fail.
|
// doubles which causes this test to fail.
|
||||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) !=
|
if(x1(std::numeric_limits<T>::denorm_min()) !=
|
||||||
HASH_NAMESPACE::hash_value(boost::hash_detail::limits<T>::denorm_min()))
|
HASH_NAMESPACE::hash_value(std::numeric_limits<T>::denorm_min()))
|
||||||
{
|
{
|
||||||
std::cerr<<"x1(boost::hash_detail::limits<T>::denorm_min()) = "
|
std::cerr<<"x1(std::numeric_limits<T>::denorm_min()) = "
|
||||||
<< x1(boost::hash_detail::limits<T>::denorm_min())
|
<< x1(std::numeric_limits<T>::denorm_min())
|
||||||
<< "\nhash_value(boost::hash_detail::limits<T>::denorm_min()) = "
|
<< "\nhash_value(std::numeric_limits<T>::denorm_min()) = "
|
||||||
<< HASH_NAMESPACE::hash_value(
|
<< HASH_NAMESPACE::hash_value(
|
||||||
boost::hash_detail::limits<T>::denorm_min())
|
std::numeric_limits<T>::denorm_min())
|
||||||
<< "\nx1(0) = "<<x1(0)<<"\n";
|
<< "\nx1(0) = "<<x1(0)<<"\n";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -193,12 +188,12 @@ void float_tests(char const* name, T* = 0)
|
|||||||
|
|
||||||
// NaN also causes borland to crash.
|
// NaN also causes borland to crash.
|
||||||
#if !defined(__BORLANDC__)
|
#if !defined(__BORLANDC__)
|
||||||
if(boost::hash_detail::limits<T>::has_quiet_NaN) {
|
if(std::numeric_limits<T>::has_quiet_NaN) {
|
||||||
if(x1(boost::hash_detail::limits<T>::quiet_NaN()) == x1(1.0)) {
|
if(x1(std::numeric_limits<T>::quiet_NaN()) == x1(1.0)) {
|
||||||
std::cerr<<"x1(quiet_NaN) == x1(1.0) == "<<x1(1.0)<<"\n";
|
std::cerr<<"x1(quiet_NaN) == x1(1.0) == "<<x1(1.0)<<"\n";
|
||||||
}
|
}
|
||||||
BOOST_TEST(x1(boost::hash_detail::limits<T>::quiet_NaN()) ==
|
BOOST_TEST(x1(std::numeric_limits<T>::quiet_NaN()) ==
|
||||||
HASH_NAMESPACE::hash_value(boost::hash_detail::limits<T>::quiet_NaN()));
|
HASH_NAMESPACE::hash_value(std::numeric_limits<T>::quiet_NaN()));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -231,6 +226,3 @@ int main()
|
|||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2006-2007 Daniel James.
|
// Copyright Daniel James 2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2006-2007 Daniel James.
|
// Copyright Daniel James 2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2006-2007 Daniel James.
|
// Copyright Daniel James 2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// This checks that template code implemented using hash_fwd will work.
|
// This checks that template code implemented using hash_fwd will work.
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2006-2007 Daniel James.
|
// Copyright Daniel James 2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// This test just makes sure a header which uses hash_fwd can compile without
|
// This test just makes sure a header which uses hash_fwd can compile without
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2006-2007 Daniel James.
|
// Copyright Daniel James 2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// This test demonstrates an ADL bug in Borland 5.5 where ADL isn't performed
|
// This test demonstrates an ADL bug in Borland 5.5 where ADL isn't performed
|
||||||
@@ -44,7 +44,7 @@ namespace boost
|
|||||||
# ifdef TEST_STD_INCLUDES
|
# ifdef TEST_STD_INCLUDES
|
||||||
# include <functional>
|
# include <functional>
|
||||||
# else
|
# else
|
||||||
# include <boost/functional/hash.hpp>
|
# include <boost/functional/hash/hash.hpp>
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#if !defined(CONTAINER_TYPE)
|
#if !defined(CONTAINER_TYPE)
|
||||||
@@ -9,11 +9,6 @@
|
|||||||
|
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#include <boost/preprocessor/cat.hpp>
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable:4245) // signed/unsigned mismatch
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
||||||
{
|
{
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -65,9 +60,5 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef CONTAINER_TYPE
|
#undef CONTAINER_TYPE
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2006-2007 Daniel James.
|
// Copyright Daniel James 2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define HASH_NAMESPACE boost
|
#define HASH_NAMESPACE boost
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2006-2007 Daniel James.
|
// Copyright Daniel James 2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define HASH_NAMESPACE boost
|
#define HASH_NAMESPACE boost
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2006-2007 Daniel James.
|
// Copyright Daniel James 2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define HASH_NAMESPACE boost
|
#define HASH_NAMESPACE boost
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
@@ -21,24 +21,17 @@
|
|||||||
|
|
||||||
#include "./compile_time.hpp"
|
#include "./compile_time.hpp"
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable:4127) // conditional expression is constant
|
|
||||||
#pragma warning(disable:4309) // truncation of constant value
|
|
||||||
#pragma warning(disable:4310) // cast truncates constant value
|
|
||||||
#endif
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void numeric_test(T*)
|
void numeric_test(T*)
|
||||||
{
|
{
|
||||||
typedef boost::hash_detail::limits<T> limits;
|
typedef std::numeric_limits<T> limits;
|
||||||
|
|
||||||
compile_time_tests((T*) 0);
|
compile_time_tests((T*) 0);
|
||||||
|
|
||||||
HASH_NAMESPACE::hash<T> x1;
|
HASH_NAMESPACE::hash<T> x1;
|
||||||
HASH_NAMESPACE::hash<T> x2;
|
HASH_NAMESPACE::hash<T> x2;
|
||||||
|
|
||||||
T v1 = (T) -5;
|
T v1 = -5;
|
||||||
BOOST_TEST(x1(v1) == x2(v1));
|
BOOST_TEST(x1(v1) == x2(v1));
|
||||||
BOOST_TEST(x1(T(-5)) == x2(T(-5)));
|
BOOST_TEST(x1(T(-5)) == x2(T(-5)));
|
||||||
BOOST_TEST(x1(T(0)) == x2(T(0)));
|
BOOST_TEST(x1(T(0)) == x2(T(0)));
|
||||||
@@ -55,8 +48,7 @@ void numeric_test(T*)
|
|||||||
|
|
||||||
if (limits::is_integer)
|
if (limits::is_integer)
|
||||||
{
|
{
|
||||||
BOOST_TEST(HASH_NAMESPACE::hash_value(T((std::size_t)-5))
|
BOOST_TEST(HASH_NAMESPACE::hash_value(T(-5)) == (std::size_t)T(-5));
|
||||||
== (std::size_t)T(-5));
|
|
||||||
BOOST_TEST(HASH_NAMESPACE::hash_value(T(0)) == (std::size_t)T(0u));
|
BOOST_TEST(HASH_NAMESPACE::hash_value(T(0)) == (std::size_t)T(0u));
|
||||||
BOOST_TEST(HASH_NAMESPACE::hash_value(T(10)) == (std::size_t)T(10u));
|
BOOST_TEST(HASH_NAMESPACE::hash_value(T(10)) == (std::size_t)T(10u));
|
||||||
BOOST_TEST(HASH_NAMESPACE::hash_value(T(25)) == (std::size_t)T(25u));
|
BOOST_TEST(HASH_NAMESPACE::hash_value(T(25)) == (std::size_t)T(25u));
|
||||||
@@ -67,7 +59,7 @@ void numeric_test(T*)
|
|||||||
template <class T>
|
template <class T>
|
||||||
void limits_test(T*)
|
void limits_test(T*)
|
||||||
{
|
{
|
||||||
typedef boost::hash_detail::limits<T> limits;
|
typedef std::numeric_limits<T> limits;
|
||||||
|
|
||||||
if(limits::is_specialized)
|
if(limits::is_specialized)
|
||||||
{
|
{
|
||||||
@@ -98,7 +90,7 @@ void limits_test(T*)
|
|||||||
template <class T>
|
template <class T>
|
||||||
void poor_quality_tests(T*)
|
void poor_quality_tests(T*)
|
||||||
{
|
{
|
||||||
typedef boost::hash_detail::limits<T> limits;
|
typedef std::numeric_limits<T> limits;
|
||||||
|
|
||||||
HASH_NAMESPACE::hash<T> x1;
|
HASH_NAMESPACE::hash<T> x1;
|
||||||
HASH_NAMESPACE::hash<T> x2;
|
HASH_NAMESPACE::hash<T> x2;
|
||||||
@@ -113,29 +105,16 @@ void poor_quality_tests(T*)
|
|||||||
BOOST_TEST(x1((limits::max)()) != x2((limits::max)() - 1));
|
BOOST_TEST(x1((limits::max)()) != x2((limits::max)() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void bool_test()
|
|
||||||
{
|
|
||||||
HASH_NAMESPACE::hash<bool> x1;
|
|
||||||
HASH_NAMESPACE::hash<bool> x2;
|
|
||||||
|
|
||||||
BOOST_TEST(x1(true) == x2(true));
|
|
||||||
BOOST_TEST(x1(false) == x2(false));
|
|
||||||
BOOST_TEST(x1(true) != x2(false));
|
|
||||||
BOOST_TEST(x1(false) != x2(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define NUMERIC_TEST(type, name) \
|
#define NUMERIC_TEST(type, name) \
|
||||||
std::cerr<<"Testing: " BOOST_STRINGIZE(name) "\n"; \
|
std::cerr<<"Testing: " BOOST_STRINGIZE(name) "\n"; \
|
||||||
numeric_test((type*) 0); \
|
numeric_test((type*) 0); \
|
||||||
limits_test((type*) 0); \
|
limits_test((type*) 0); \
|
||||||
poor_quality_tests((type*) 0);
|
poor_quality_tests((type*) 0);
|
||||||
#define NUMERIC_TEST_NO_LIMITS(type, name) \
|
|
||||||
std::cerr<<"Testing: " BOOST_STRINGIZE(name) "\n"; \
|
|
||||||
numeric_test((type*) 0); \
|
|
||||||
poor_quality_tests((type*) 0);
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
NUMERIC_TEST(bool, bool)
|
||||||
NUMERIC_TEST(char, char)
|
NUMERIC_TEST(char, char)
|
||||||
NUMERIC_TEST(signed char, schar)
|
NUMERIC_TEST(signed char, schar)
|
||||||
NUMERIC_TEST(unsigned char, uchar)
|
NUMERIC_TEST(unsigned char, uchar)
|
||||||
@@ -149,20 +128,11 @@ int main()
|
|||||||
NUMERIC_TEST(long, hash_long)
|
NUMERIC_TEST(long, hash_long)
|
||||||
NUMERIC_TEST(unsigned long, ulong)
|
NUMERIC_TEST(unsigned long, ulong)
|
||||||
|
|
||||||
#if defined(BOOST_HAS_LONG_LONG)
|
|
||||||
NUMERIC_TEST_NO_LIMITS(long long, hash_longlong)
|
|
||||||
NUMERIC_TEST_NO_LIMITS(unsigned long long, ulonglong)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
NUMERIC_TEST(float, float)
|
NUMERIC_TEST(float, float)
|
||||||
NUMERIC_TEST(double, double)
|
NUMERIC_TEST(double, double)
|
||||||
NUMERIC_TEST(long double, ldouble)
|
NUMERIC_TEST(long double, ldouble)
|
||||||
|
|
||||||
bool_test();
|
|
||||||
|
|
||||||
return boost::report_errors();
|
return boost::report_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#if !defined(CONTAINER_TYPE)
|
#if !defined(CONTAINER_TYPE)
|
||||||
@@ -9,11 +9,6 @@
|
|||||||
|
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#include <boost/preprocessor/cat.hpp>
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable:4245) // signed/unsigned mismatch
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
||||||
{
|
{
|
||||||
template <class T>
|
template <class T>
|
||||||
@@ -68,9 +63,5 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef CONTAINER_TYPE
|
#undef CONTAINER_TYPE
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#if !defined(CONTAINER_TYPE)
|
#if !defined(CONTAINER_TYPE)
|
||||||
@@ -9,17 +9,12 @@
|
|||||||
|
|
||||||
#include <boost/preprocessor/cat.hpp>
|
#include <boost/preprocessor/cat.hpp>
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#pragma warning(push)
|
|
||||||
#pragma warning(disable:4245) // signed/unsigned mismatch
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
||||||
{
|
{
|
||||||
template <class T>
|
template <class T>
|
||||||
void integer_tests(T* = 0)
|
void integer_tests(T* = 0)
|
||||||
{
|
{
|
||||||
const int number_of_containers = 12;
|
const int number_of_containers = 11;
|
||||||
T containers[number_of_containers];
|
T containers[number_of_containers];
|
||||||
|
|
||||||
for(int i = 0; i < 5; ++i) {
|
for(int i = 0; i < 5; ++i) {
|
||||||
@@ -35,11 +30,6 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
|||||||
containers[9].insert(-1);
|
containers[9].insert(-1);
|
||||||
containers[10].insert(-1);
|
containers[10].insert(-1);
|
||||||
containers[10].insert(1);
|
containers[10].insert(1);
|
||||||
containers[11].insert(1);
|
|
||||||
containers[11].insert(2);
|
|
||||||
containers[11].insert(3);
|
|
||||||
containers[11].insert(4);
|
|
||||||
containers[11].insert(5);
|
|
||||||
|
|
||||||
HASH_NAMESPACE::hash<T> hasher;
|
HASH_NAMESPACE::hash<T> hasher;
|
||||||
|
|
||||||
@@ -71,9 +61,5 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(BOOST_MSVC)
|
|
||||||
#pragma warning(pop)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef CONTAINER_TYPE
|
#undef CONTAINER_TYPE
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// On some compilers hash_value isn't available for arrays, so I test it
|
// On some compilers hash_value isn't available for arrays, so I test it
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include "./config.hpp"
|
#include "./config.hpp"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2006-2007 Daniel James.
|
// Copyright Daniel James 2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define HASH_NAMESPACE boost
|
#define HASH_NAMESPACE boost
|
||||||
@@ -17,7 +17,6 @@ int f(std::size_t hash1, int* x1) {
|
|||||||
std::vector<std::size_t> x;
|
std::vector<std::size_t> x;
|
||||||
x.push_back(*x1);
|
x.push_back(*x1);
|
||||||
HASH_NAMESPACE::hash<std::vector<std::size_t> > vector_hasher;
|
HASH_NAMESPACE::hash<std::vector<std::size_t> > vector_hasher;
|
||||||
BOOST_TEST(vector_hasher(x) == HASH_NAMESPACE::hash_value(x));
|
return vector_hasher(x) != HASH_NAMESPACE::hash_value(x);
|
||||||
return boost::report_errors();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#define HASH_NAMESPACE boost
|
#define HASH_NAMESPACE boost
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/functional/hash.hpp>
|
#include <boost/functional/hash.hpp>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#if !defined(BOOST_DETAIL_CONTAINER_FWD_HPP)
|
#if !defined(BOOST_DETAIL_CONTAINER_FWD_HPP)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#if !defined(BOOST_FUNCTIONAL_DETAIL_FLOAT_FUNCTIONS_HPP)
|
#if !defined(BOOST_FUNCTIONAL_DETAIL_FLOAT_FUNCTIONS_HPP)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// Based on Peter Dimov's proposal
|
// Based on Peter Dimov's proposal
|
||||||
@@ -15,9 +15,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/functional/detail/float_functions.hpp>
|
#include <boost/functional/detail/float_functions.hpp>
|
||||||
#include <boost/integer/static_log2.hpp>
|
|
||||||
#include <boost/limits.hpp>
|
#include <boost/limits.hpp>
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
// Don't use fpclassify or _fpclass for stlport.
|
// Don't use fpclassify or _fpclass for stlport.
|
||||||
#if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
#if !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION)
|
||||||
@@ -35,43 +35,10 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// On OpenBSD, numeric_limits is not reliable for long doubles, but
|
|
||||||
// the macros defined in <float.h> are.
|
|
||||||
|
|
||||||
#if defined(__OpenBSD__)
|
|
||||||
#include <float.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
namespace hash_detail
|
namespace hash_detail
|
||||||
{
|
{
|
||||||
template <class T>
|
|
||||||
struct limits : std::numeric_limits<T> {};
|
|
||||||
|
|
||||||
#if defined(__OpenBSD__)
|
|
||||||
template <>
|
|
||||||
struct limits<long double>
|
|
||||||
: std::numeric_limits<long double>
|
|
||||||
{
|
|
||||||
static long double epsilon() {
|
|
||||||
return LDBL_EPSILON;
|
|
||||||
}
|
|
||||||
|
|
||||||
static long double (max)() {
|
|
||||||
return LDBL_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
static long double (min)() {
|
|
||||||
return LDBL_MIN;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOST_STATIC_CONSTANT(int, digits = LDBL_MANT_DIG);
|
|
||||||
BOOST_STATIC_CONSTANT(int, max_exponent = LDBL_MAX_EXP);
|
|
||||||
BOOST_STATIC_CONSTANT(int, min_exponent = LDBL_MIN_EXP);
|
|
||||||
};
|
|
||||||
#endif // __OpenBSD__
|
|
||||||
|
|
||||||
inline void hash_float_combine(std::size_t& seed, std::size_t value)
|
inline void hash_float_combine(std::size_t& seed, std::size_t value)
|
||||||
{
|
{
|
||||||
seed ^= value + (seed<<6) + (seed>>2);
|
seed ^= value + (seed<<6) + (seed>>2);
|
||||||
@@ -81,35 +48,21 @@ namespace boost
|
|||||||
inline std::size_t float_hash_impl(T v)
|
inline std::size_t float_hash_impl(T v)
|
||||||
{
|
{
|
||||||
int exp = 0;
|
int exp = 0;
|
||||||
|
errno = 0;
|
||||||
|
v = boost::hash_detail::call_frexp(v, &exp);
|
||||||
|
if(errno) return 0;
|
||||||
|
|
||||||
// The result of frexp is always between 0.5 and 1, so its
|
std::size_t seed = 0;
|
||||||
// top bit will always be 1. Subtract by 0.5 to remove that.
|
|
||||||
if(v >= 0) {
|
|
||||||
v = boost::hash_detail::call_frexp(v, &exp) - T(0.5);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
v = -boost::hash_detail::call_frexp(v, &exp) - T(0.5);
|
|
||||||
exp = ~exp;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Of course, this doesn't pass when hashing infinity or NaN.
|
|
||||||
//BOOST_ASSERT(0 <= v && v < 0.5);
|
|
||||||
|
|
||||||
v = boost::hash_detail::call_ldexp(v,
|
|
||||||
limits<std::size_t>::digits + 1);
|
|
||||||
std::size_t seed = static_cast<std::size_t>(v);
|
|
||||||
v -= seed;
|
|
||||||
|
|
||||||
// ceiling(digits(T) * log2(radix(T))/ digits(size_t)) - 1;
|
|
||||||
std::size_t const length
|
std::size_t const length
|
||||||
= (limits<T>::digits *
|
= (std::numeric_limits<T>::digits +
|
||||||
boost::static_log2<limits<T>::radix>::value - 1)
|
std::numeric_limits<int>::digits - 1)
|
||||||
/ limits<std::size_t>::digits;
|
/ std::numeric_limits<int>::digits;
|
||||||
|
|
||||||
for(std::size_t i = 0; i != length; ++i)
|
for(std::size_t i = 0; i < length; ++i)
|
||||||
{
|
{
|
||||||
v = boost::hash_detail::call_ldexp(v, limits<std::size_t>::digits);
|
v = boost::hash_detail::call_ldexp(v, std::numeric_limits<int>::digits);
|
||||||
std::size_t part = static_cast<std::size_t>(v);
|
int const part = static_cast<int>(v);
|
||||||
v -= part;
|
v -= part;
|
||||||
hash_float_combine(seed, part);
|
hash_float_combine(seed, part);
|
||||||
}
|
}
|
||||||
@@ -161,7 +114,7 @@ namespace boost
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
return v == 0 ? 0 : float_hash_impl(v);
|
return float_hash_impl(v);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// Based on Peter Dimov's proposal
|
// Based on Peter Dimov's proposal
|
||||||
@@ -8,7 +8,3 @@
|
|||||||
// issue 6.18.
|
// issue 6.18.
|
||||||
|
|
||||||
#include <boost/functional/hash/hash.hpp>
|
#include <boost/functional/hash/hash.hpp>
|
||||||
|
|
||||||
#if !defined(BOOST_HASH_NO_EXTENSIONS)
|
|
||||||
#include <boost/functional/hash/extensions.hpp>
|
|
||||||
#endif
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2006 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// Based on Peter Dimov's proposal
|
// Based on Peter Dimov's proposal
|
||||||
|
@@ -1,182 +0,0 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 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.
|
|
||||||
|
|
||||||
#if !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP)
|
|
||||||
#define BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
|
||||||
# pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace boost
|
|
||||||
{
|
|
||||||
|
|
||||||
#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
|
||||||
namespace hash_detail
|
|
||||||
{
|
|
||||||
template <bool IsArray>
|
|
||||||
struct call_hash_impl
|
|
||||||
{
|
|
||||||
template <class T>
|
|
||||||
struct inner
|
|
||||||
{
|
|
||||||
static std::size_t call(T const& v)
|
|
||||||
{
|
|
||||||
using namespace boost;
|
|
||||||
return hash_value(v);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct call_hash_impl<true>
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct call_hash
|
|
||||||
: public call_hash_impl<boost::is_array<T>::value>
|
|
||||||
::BOOST_NESTED_TEMPLATE inner<T>
|
|
||||||
{
|
|
||||||
};
|
|
||||||
}
|
|
||||||
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
|
||||||
|
|
||||||
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
|
||||||
|
|
||||||
template <class T> struct hash
|
|
||||||
: std::unary_function<T, std::size_t>
|
|
||||||
{
|
|
||||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
|
||||||
std::size_t operator()(T const& val) const
|
|
||||||
{
|
|
||||||
return hash_value(val);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
std::size_t operator()(T const& val) const
|
|
||||||
{
|
|
||||||
return hash_detail::call_hash<T>::call(val);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#if BOOST_WORKAROUND(__DMC__, <= 0x848)
|
|
||||||
template <class T, unsigned int n> struct hash<T[n]>
|
|
||||||
: std::unary_function<T[n], std::size_t>
|
|
||||||
{
|
|
||||||
std::size_t operator()(const T* val) const
|
|
||||||
{
|
|
||||||
return boost::hash_range(val, val+n);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
|
||||||
|
|
||||||
// On compilers without partial specialization, boost::hash<T>
|
|
||||||
// has already been declared to deal with pointers, so just
|
|
||||||
// need to supply the non-pointer version.
|
|
||||||
|
|
||||||
namespace hash_detail
|
|
||||||
{
|
|
||||||
template <bool IsPointer>
|
|
||||||
struct hash_impl;
|
|
||||||
|
|
||||||
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
|
||||||
|
|
||||||
template <>
|
|
||||||
struct hash_impl<false>
|
|
||||||
{
|
|
||||||
template <class T>
|
|
||||||
struct inner
|
|
||||||
: std::unary_function<T, std::size_t>
|
|
||||||
{
|
|
||||||
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
|
||||||
std::size_t operator()(T const& val) const
|
|
||||||
{
|
|
||||||
return hash_value(val);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
std::size_t operator()(T const& val) const
|
|
||||||
{
|
|
||||||
return hash_detail::call_hash<T>::call(val);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#else // Visual C++ 6.5
|
|
||||||
|
|
||||||
// There's probably a more elegant way to Visual C++ 6.5 to work
|
|
||||||
// but I don't know what it is.
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2007. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// Based on Peter Dimov's proposal
|
// Based on Peter Dimov's proposal
|
||||||
@@ -10,10 +10,6 @@
|
|||||||
#if !defined(BOOST_FUNCTIONAL_HASH_HASH_HPP)
|
#if !defined(BOOST_FUNCTIONAL_HASH_HASH_HPP)
|
||||||
#define BOOST_FUNCTIONAL_HASH_HASH_HPP
|
#define BOOST_FUNCTIONAL_HASH_HASH_HPP
|
||||||
|
|
||||||
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
|
|
||||||
# pragma once
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <boost/functional/hash_fwd.hpp>
|
#include <boost/functional/hash_fwd.hpp>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <boost/functional/detail/hash_float.hpp>
|
#include <boost/functional/detail/hash_float.hpp>
|
||||||
@@ -32,24 +28,29 @@
|
|||||||
#include <boost/type_traits/is_const.hpp>
|
#include <boost/type_traits/is_const.hpp>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
# pragma warning(push)
|
||||||
|
# pragma warning(disable:4267)
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||||
|
// Borland complains about an ambiguous function overload
|
||||||
|
// when compiling boost::hash<bool>.
|
||||||
std::size_t hash_value(bool);
|
std::size_t hash_value(bool);
|
||||||
std::size_t hash_value(char);
|
#endif
|
||||||
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(int);
|
||||||
std::size_t hash_value(unsigned int);
|
std::size_t hash_value(unsigned int);
|
||||||
std::size_t hash_value(long);
|
std::size_t hash_value(long);
|
||||||
std::size_t hash_value(unsigned long);
|
std::size_t hash_value(unsigned long);
|
||||||
|
|
||||||
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
#if defined(BOOST_HAS_LONG_LONG) && defined(_M_X64) && defined(_WIN64)
|
||||||
std::size_t hash_value(wchar_t);
|
// On 64-bit windows std::size_t is a typedef for unsigned long long, which
|
||||||
#endif
|
// isn't due to be supported until Boost 1.35. So add support here.
|
||||||
|
// (Technically, Boost.Hash isn't actually documented as supporting
|
||||||
#if defined(BOOST_HAS_LONG_LONG)
|
// std::size_t. But it would be pretty silly not to).
|
||||||
std::size_t hash_value(long long);
|
std::size_t hash_value(long long);
|
||||||
std::size_t hash_value(unsigned long long);
|
std::size_t hash_value(unsigned long long);
|
||||||
#endif
|
#endif
|
||||||
@@ -92,84 +93,14 @@ namespace boost
|
|||||||
template <class K, class T, class C, class A>
|
template <class K, class T, class C, class A>
|
||||||
std::size_t hash_value(std::multimap<K, T, C, A> const& v);
|
std::size_t hash_value(std::multimap<K, T, C, A> const& v);
|
||||||
|
|
||||||
template <class T>
|
|
||||||
std::size_t hash_value(std::complex<T> const&);
|
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
|
|
||||||
namespace hash_detail
|
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x551))
|
||||||
{
|
|
||||||
template <class T>
|
|
||||||
inline std::size_t hash_value_signed(T val)
|
|
||||||
{
|
|
||||||
const int size_t_bits = std::numeric_limits<std::size_t>::digits;
|
|
||||||
// ceiling(std::numeric_limits<T>::digits / size_t_bits) - 1
|
|
||||||
const int length = (std::numeric_limits<T>::digits - 1)
|
|
||||||
/ size_t_bits;
|
|
||||||
|
|
||||||
std::size_t seed = 0;
|
|
||||||
T positive = val < 0 ? -1 - val : val;
|
|
||||||
|
|
||||||
// Hopefully, this loop can be unrolled.
|
|
||||||
for(unsigned int i = length * size_t_bits; i > 0; i -= size_t_bits)
|
|
||||||
{
|
|
||||||
seed ^= (std::size_t) (positive >> i) + (seed<<6) + (seed>>2);
|
|
||||||
}
|
|
||||||
seed ^= (std::size_t) val + (seed<<6) + (seed>>2);
|
|
||||||
|
|
||||||
return seed;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
inline std::size_t hash_value_unsigned(T val)
|
|
||||||
{
|
|
||||||
const int size_t_bits = std::numeric_limits<std::size_t>::digits;
|
|
||||||
// ceiling(std::numeric_limits<T>::digits / size_t_bits) - 1
|
|
||||||
const int length = (std::numeric_limits<T>::digits - 1)
|
|
||||||
/ size_t_bits;
|
|
||||||
|
|
||||||
std::size_t seed = 0;
|
|
||||||
|
|
||||||
// Hopefully, this loop can be unrolled.
|
|
||||||
for(unsigned int i = length * size_t_bits; i > 0; i -= size_t_bits)
|
|
||||||
{
|
|
||||||
seed ^= (std::size_t) (val >> i) + (seed<<6) + (seed>>2);
|
|
||||||
}
|
|
||||||
seed ^= (std::size_t) val + (seed<<6) + (seed>>2);
|
|
||||||
|
|
||||||
return seed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::size_t hash_value(bool v)
|
inline std::size_t hash_value(bool v)
|
||||||
{
|
{
|
||||||
return static_cast<std::size_t>(v);
|
return static_cast<std::size_t>(v);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
inline std::size_t hash_value(char v)
|
|
||||||
{
|
|
||||||
return static_cast<std::size_t>(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::size_t hash_value(unsigned char v)
|
|
||||||
{
|
|
||||||
return static_cast<std::size_t>(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::size_t hash_value(signed char v)
|
|
||||||
{
|
|
||||||
return static_cast<std::size_t>(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::size_t hash_value(short v)
|
|
||||||
{
|
|
||||||
return static_cast<std::size_t>(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::size_t hash_value(unsigned short v)
|
|
||||||
{
|
|
||||||
return static_cast<std::size_t>(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline std::size_t hash_value(int v)
|
inline std::size_t hash_value(int v)
|
||||||
{
|
{
|
||||||
@@ -191,22 +122,15 @@ namespace boost
|
|||||||
return static_cast<std::size_t>(v);
|
return static_cast<std::size_t>(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
#if defined(BOOST_HAS_LONG_LONG) && defined(_M_X64) && defined(_WIN64)
|
||||||
inline std::size_t hash_value(wchar_t v)
|
|
||||||
{
|
|
||||||
return static_cast<std::size_t>(v);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(BOOST_HAS_LONG_LONG)
|
|
||||||
inline std::size_t hash_value(long long v)
|
inline std::size_t hash_value(long long v)
|
||||||
{
|
{
|
||||||
return hash_detail::hash_value_signed(v);
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::size_t hash_value(unsigned long long v)
|
inline std::size_t hash_value(unsigned long long v)
|
||||||
{
|
{
|
||||||
return hash_detail::hash_value_unsigned(v);
|
return v;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -368,15 +292,6 @@ namespace boost
|
|||||||
return hash_range(v.begin(), v.end());
|
return hash_range(v.begin(), v.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
|
||||||
std::size_t hash_value(std::complex<T> const& v)
|
|
||||||
{
|
|
||||||
boost::hash<T> hasher;
|
|
||||||
std::size_t seed = hasher(v.imag());
|
|
||||||
seed ^= hasher(v.real()) + (seed<<6) + (seed>>2);
|
|
||||||
return seed;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// boost::hash
|
// boost::hash
|
||||||
//
|
//
|
||||||
@@ -507,3 +422,181 @@ namespace boost
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // BOOST_FUNCTIONAL_HASH_HASH_HPP
|
#endif // BOOST_FUNCTIONAL_HASH_HASH_HPP
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#if !defined(BOOST_HASH_NO_EXTENSIONS) \
|
||||||
|
&& !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP)
|
||||||
|
#define BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
#if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
||||||
|
namespace hash_detail
|
||||||
|
{
|
||||||
|
template <bool IsArray>
|
||||||
|
struct call_hash_impl
|
||||||
|
{
|
||||||
|
template <class T>
|
||||||
|
struct inner
|
||||||
|
{
|
||||||
|
static std::size_t call(T const& v)
|
||||||
|
{
|
||||||
|
using namespace boost;
|
||||||
|
return hash_value(v);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct call_hash_impl<true>
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
struct call_hash
|
||||||
|
: public call_hash_impl<boost::is_array<T>::value>
|
||||||
|
::BOOST_NESTED_TEMPLATE inner<T>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
|
||||||
|
|
||||||
|
template <class T> struct hash
|
||||||
|
: std::unary_function<T, std::size_t>
|
||||||
|
{
|
||||||
|
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
||||||
|
std::size_t operator()(T const& val) const
|
||||||
|
{
|
||||||
|
return hash_value(val);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
std::size_t operator()(T const& val) const
|
||||||
|
{
|
||||||
|
return hash_detail::call_hash<T>::call(val);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#if BOOST_WORKAROUND(__DMC__, <= 0x848)
|
||||||
|
template <class T, unsigned int n> struct hash<T[n]>
|
||||||
|
: std::unary_function<T[n], std::size_t>
|
||||||
|
{
|
||||||
|
std::size_t operator()(const T* val) const
|
||||||
|
{
|
||||||
|
return boost::hash_range(val, val+n);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||||
|
|
||||||
|
// On compilers without partial specialization, boost::hash<T>
|
||||||
|
// has already been declared to deal with pointers, so just
|
||||||
|
// need to supply the non-pointer version.
|
||||||
|
|
||||||
|
namespace hash_detail
|
||||||
|
{
|
||||||
|
template <bool IsPointer>
|
||||||
|
struct hash_impl;
|
||||||
|
|
||||||
|
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct hash_impl<false>
|
||||||
|
{
|
||||||
|
template <class T>
|
||||||
|
struct inner
|
||||||
|
: std::unary_function<T, std::size_t>
|
||||||
|
{
|
||||||
|
#if !defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING)
|
||||||
|
std::size_t operator()(T const& val) const
|
||||||
|
{
|
||||||
|
return hash_value(val);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
std::size_t operator()(T const& val) const
|
||||||
|
{
|
||||||
|
return hash_detail::call_hash<T>::call(val);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#else // Visual C++ 6.5
|
||||||
|
|
||||||
|
// There's probably a more elegant way to Visual C++ 6.5 to work
|
||||||
|
// but I don't know what it is.
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(BOOST_MSVC)
|
||||||
|
# pragma warning(pop)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2006 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// Based on Peter Dimov's proposal
|
// Based on Peter Dimov's proposal
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2006 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// Based on Peter Dimov's proposal
|
// Based on Peter Dimov's proposal
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2006 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// Based on Peter Dimov's proposal
|
// Based on Peter Dimov's proposal
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2006 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// Based on Peter Dimov's proposal
|
// Based on Peter Dimov's proposal
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2006 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// Based on Peter Dimov's proposal
|
// Based on Peter Dimov's proposal
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
// Copyright 2005-2007 Daniel James.
|
// Copyright Daniel James 2005-2006. Use, modification, and distribution are
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// subject to 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)
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
// Based on Peter Dimov's proposal
|
// Based on Peter Dimov's proposal
|
||||||
|
Reference in New Issue
Block a user