mirror of
https://github.com/boostorg/functional.git
synced 2025-08-01 21:44:28 +02:00
Merge all hash changes from trunk.
[SVN r46343]
This commit is contained in:
@@ -1,9 +1,28 @@
|
||||
|
||||
# Copyright 2005 Daniel James.
|
||||
# Copyright 2005-2008 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)
|
||||
|
||||
using quickbook ;
|
||||
|
||||
xml hash : hash.qbk ;
|
||||
boostbook standalone : hash ;
|
||||
boostbook standalone : hash :
|
||||
<xsl:param>admon.graphics.path=images/
|
||||
<xsl:param>navig.graphics.path=images/
|
||||
<xsl:param>html.stylesheet=boostbook.css
|
||||
<xsl:param>boost.root=../../../../..
|
||||
<xsl:param>boost.libraries=../../../../libraries.htm
|
||||
<xsl:param>chunk.first.sections=1
|
||||
<xsl:param>chunk.section.depth=2
|
||||
<xsl:param>generate.section.toc.level=2
|
||||
<xsl:param>toc.section.depth=1
|
||||
<xsl:param>toc.max.depth=1
|
||||
|
||||
<dependency>css
|
||||
<dependency>images
|
||||
;
|
||||
|
||||
install css : [ glob $(BOOST_ROOT)/doc/src/*.css ]
|
||||
: <location>html ;
|
||||
install images : [ glob $(BOOST_ROOT)/doc/src/images/*.png ]
|
||||
: <location>html/images ;
|
||||
explicit css ;
|
||||
explicit images ;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
[/ Copyright 2005-2007 Daniel James.
|
||||
[/ Copyright 2005-2008 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) ]
|
||||
|
||||
@@ -9,24 +9,54 @@
|
||||
|
||||
* Initial Release
|
||||
|
||||
[h2 Changes in Boost 1.33.1]
|
||||
[h2 Boost 1.33.1]
|
||||
|
||||
* Fixed the points example, as pointed out by 沈慧峰.
|
||||
|
||||
[h2 Changes in Boost 1.34.0]
|
||||
[h2 Boost 1.34.0]
|
||||
|
||||
* Use declarations for standard classes, so that the library
|
||||
doesn't need to include all of their headers
|
||||
* Deprecated the `<boost/functional/hash/*.hpp>` headers. Now a single header,
|
||||
<[headerref boost/functional/hash.hpp]> is used.
|
||||
* Add support for the `BOOST_HASH_NO_EXTENSIONS` macro, which
|
||||
disables the extensions to TR1
|
||||
disables the extensions to TR1.
|
||||
|
||||
* Minor improvements to the hash functions for floating point numbers.
|
||||
* Update the portable example to hopefully be more generally portable.
|
||||
|
||||
[h2 Future Developments]
|
||||
[h2 Boost 1.34.1]
|
||||
|
||||
* A more portable hash function, as described by Daniel Krügler in
|
||||
[@http://lists.boost.org/boost-users/2005/08/13418.php a post to the boost users list].
|
||||
* Implement `hash_value` for more classes, including `std::complex`.
|
||||
* [@http://svn.boost.org/trac/boost/ticket/952 Ticket 952]:
|
||||
Suppress incorrect 64-bit warning on Visual C++.
|
||||
|
||||
[h2 Boost 1.35.0]
|
||||
|
||||
* Support for `long long`, `std::complex`.
|
||||
* Improved algorithm for hashing floating point numbers:
|
||||
* Improved portablity, as described by Daniel Krügler in
|
||||
[@http://lists.boost.org/boost-users/2005/08/13418.php
|
||||
a post to the boost users list].
|
||||
* Fits more information into each combine loop, which can reduce the
|
||||
the number of times combine is called and hopefully give a better
|
||||
quality hash function.
|
||||
* Improved the algorithm for hashing floating point numbers.
|
||||
* On Cygwin use a binary hash function for floating point numbers, as
|
||||
Cygwin doesn't have decent floating point functions for `long double`.
|
||||
* Never uses `fpclass` which doesn't support `long double`.
|
||||
* [@http://svn.boost.org/trac/boost/ticket/1064 Ticket 1064]:
|
||||
Removed unnecessary use of `errno`.
|
||||
* Explicitly overload for more built in types.
|
||||
* Minor improvements to the documentation.
|
||||
* A few bug and warning fixes:
|
||||
* [@http://svn.boost.org/trac/boost/ticket/1509 Ticket 1509]:
|
||||
Suppress another Visual C++ warning.
|
||||
* Some workarounds for the Sun compilers.
|
||||
|
||||
[h2 Boost 1.36.0]
|
||||
|
||||
* Stop using OpenBSD's dodgy `std::numeric_limits`.
|
||||
* Using the boost typedefs for `long long` and `unsigned long long`.
|
||||
* Move the extensions into their own header.
|
||||
|
||||
[endsect]
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
[/ Copyright 2005-2007 Daniel James.
|
||||
[/ Copyright 2005-2008 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) ]
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
[library Boost.Functional/Hash
|
||||
[quickbook 1.4]
|
||||
[authors [James, Daniel]]
|
||||
[copyright 2005 2006 2007 Daniel James]
|
||||
[copyright 2005 2006 2007 2008 Daniel James]
|
||||
[purpose A TR1 hash function object that can be extended to hash user
|
||||
defined types]
|
||||
[category higher-order]
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
[/ Copyright 2005-2007 Daniel James.
|
||||
[/ Copyright 2005-2008 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) ]
|
||||
|
||||
@@ -11,10 +11,13 @@
|
||||
[def __tr1__
|
||||
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf
|
||||
TR1]]
|
||||
[def __unordered__ [link unordered Boost.Unordered]]
|
||||
[def __intrusive__ [link intrusive.unordered_set_unordered_multiset Boost.Intrusive]]
|
||||
[def __multi-index__ [@../../libs/multi_index/doc/index.html
|
||||
Boost Multi-Index Containers Library]]
|
||||
[def __multi-index-short__ [@../../libs/multi_index/doc/index.html
|
||||
Boost.MultiIndex]]
|
||||
[def __bimap__ [@../../libs/bimap/index.html Boost.Bimap]]
|
||||
[def __issues__
|
||||
[@http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1837.pdf
|
||||
Library Extension Technical Report Issues List]]
|
||||
@@ -22,8 +25,9 @@
|
||||
[def __hash-table__ [@http://en.wikipedia.org/wiki/Hash_table hash table]]
|
||||
|
||||
[classref boost::hash] is an implementation of the __hash-function__ object
|
||||
specified by the __tr1-full__ (TR1). It is intended for use as the default hash function
|
||||
for unordered associative containers, and the __multi-index__'s hash indexes.
|
||||
specified by the __tr1-full__ (TR1). It is the default hash function for
|
||||
__unordered__, __intrusive__'s unordered associative containers, and
|
||||
__multi-index-short__'s hash indicies and __bimap__'s `unordered_set_of`.
|
||||
|
||||
As it is compliant with __tr1__, it will work with:
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
[/ Copyright 2005-2007 Daniel James.
|
||||
[/ Copyright 2005-2008 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) ]
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
[/ Copyright 2005-2007 Daniel James.
|
||||
[/ Copyright 2005-2008 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) ]
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
|
||||
<!--
|
||||
Copyright Daniel James 2005-2007
|
||||
Copyright Daniel James 2005-2008
|
||||
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)
|
||||
-->
|
||||
@@ -406,6 +406,8 @@ file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
</method>
|
||||
</struct-specialization>
|
||||
|
||||
<free-function-group name="Support functions (Boost extension).">
|
||||
|
||||
<!--
|
||||
boost::hash_combine
|
||||
-->
|
||||
@@ -500,6 +502,10 @@ for(; first != last; ++first)
|
||||
</para></throws>
|
||||
</overloaded-function>
|
||||
|
||||
</free-function-group>
|
||||
|
||||
<free-function-group name="Overloadable hash implementation (Boost extension).">
|
||||
|
||||
<!--
|
||||
boost::hash_value - integers
|
||||
-->
|
||||
@@ -797,6 +803,7 @@ return seed;</programlisting></entry>
|
||||
</informaltable>
|
||||
</returns>
|
||||
</overloaded-function>
|
||||
</free-function-group>
|
||||
</namespace>
|
||||
</header>
|
||||
</library-reference>
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
[/ Copyright 2005-2007 Daniel James.
|
||||
[/ Copyright 2005-2008 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) ]
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
[/ Copyright 2005-2007 Daniel James.
|
||||
[/ Copyright 2005-2008 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) ]
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
# Copyright 2005-2007 Daniel James.
|
||||
# Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -77,7 +77,7 @@ static void test(std::pair<X, Y> const&)
|
||||
#include <complex>
|
||||
#include <utility>
|
||||
|
||||
int main()
|
||||
int main(int, char**)
|
||||
{
|
||||
std::deque<int> x1;
|
||||
std::list<std::string> x2;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#ifdef TEST_EXTENSIONS
|
||||
|
||||
@@ -37,11 +37,11 @@ void array_int_test()
|
||||
int array3[2] = {2, 3};
|
||||
HASH_NAMESPACE::hash<int[2]> hasher3;
|
||||
|
||||
BOOST_TEST(hasher1(array1)
|
||||
BOOST_CHECK(hasher1(array1)
|
||||
== HASH_NAMESPACE::hash_range(array1, array1 + length1));
|
||||
BOOST_TEST(hasher2(array2)
|
||||
BOOST_CHECK(hasher2(array2)
|
||||
== HASH_NAMESPACE::hash_range(array2, array2 + length2));
|
||||
BOOST_TEST(hasher3(array3)
|
||||
BOOST_CHECK(hasher3(array3)
|
||||
== HASH_NAMESPACE::hash_range(array3, array3 + length3));
|
||||
}
|
||||
|
||||
@@ -59,17 +59,17 @@ void two_dimensional_array_test()
|
||||
HASH_NAMESPACE::hash_combine(seed1, seed2);
|
||||
}
|
||||
|
||||
BOOST_TEST(hasher(array) == seed1);
|
||||
BOOST_TEST(hasher(array) == HASH_NAMESPACE::hash_range(array, array + 3));
|
||||
BOOST_CHECK(hasher(array) == seed1);
|
||||
BOOST_CHECK(hasher(array) == HASH_NAMESPACE::hash_range(array, array + 3));
|
||||
}
|
||||
|
||||
#endif // TEST_EXTENSIONS
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
#ifdef TEST_EXTENSIONS
|
||||
array_int_test();
|
||||
two_dimensional_array_test();
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#ifdef TEST_EXTENSIONS
|
||||
|
||||
@@ -41,13 +41,13 @@ void generic_complex_tests(std::complex<T> v)
|
||||
{
|
||||
HASH_NAMESPACE::hash<std::complex<T> > complex_hasher;
|
||||
|
||||
BOOST_TEST(complex_hasher(v) == complex_hasher(v));
|
||||
BOOST_CHECK(complex_hasher(v) == complex_hasher(v));
|
||||
|
||||
HASH_NAMESPACE::hash<T> real_hasher;
|
||||
T real = v.real();
|
||||
T imag = v.imag();
|
||||
|
||||
BOOST_TEST(real_hasher(real) == complex_hasher(std::complex<T>(real)));
|
||||
BOOST_CHECK(real_hasher(real) == complex_hasher(std::complex<T>(real)));
|
||||
|
||||
if(imag != 0 && real_hasher(real) == complex_hasher(v)) {
|
||||
std::ostringstream os;
|
||||
@@ -90,7 +90,7 @@ void complex_integral_tests(Integer*)
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
complex_float_tests((float*) 0);
|
||||
complex_float_tests((double*) 0);
|
||||
@@ -102,7 +102,7 @@ int main()
|
||||
complex_integral_tests((unsigned int*) 0);
|
||||
complex_integral_tests((unsigned long*) 0);
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace boost
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#ifdef TEST_EXTENSIONS
|
||||
|
||||
@@ -59,13 +59,13 @@ namespace boost
|
||||
void custom_tests()
|
||||
{
|
||||
HASH_NAMESPACE::hash<test::custom> custom_hasher;
|
||||
BOOST_TEST(custom_hasher(10) == 100u);
|
||||
BOOST_CHECK(custom_hasher(10) == 100u);
|
||||
test::custom x(55);
|
||||
BOOST_TEST(custom_hasher(x) == 550u);
|
||||
BOOST_CHECK(custom_hasher(x) == 550u);
|
||||
|
||||
{
|
||||
using namespace HASH_NAMESPACE;
|
||||
BOOST_TEST(custom_hasher(x) == hash_value(x));
|
||||
BOOST_CHECK(custom_hasher(x) == hash_value(x));
|
||||
}
|
||||
|
||||
std::vector<test::custom> custom_vector;
|
||||
@@ -83,17 +83,17 @@ void custom_tests()
|
||||
HASH_NAMESPACE::hash_combine(seed2, 250u);
|
||||
HASH_NAMESPACE::hash_combine(seed2, 350u);
|
||||
|
||||
BOOST_TEST(seed ==
|
||||
BOOST_CHECK(seed ==
|
||||
HASH_NAMESPACE::hash_range(custom_vector.begin(), custom_vector.end()));
|
||||
BOOST_TEST(seed == seed2);
|
||||
BOOST_CHECK(seed == seed2);
|
||||
}
|
||||
|
||||
#endif // TEST_EXTENSIONS
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
#ifdef TEST_EXTENSIONS
|
||||
custom_tests();
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2007 Daniel James.
|
||||
// Copyright 2007-2008 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)
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
int main() {
|
||||
int main(int, char**) {
|
||||
std::vector<int> v;
|
||||
boost::hash<std::vector<int> > x;
|
||||
x(v);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#ifdef TEST_EXTENSIONS
|
||||
|
||||
@@ -25,11 +25,11 @@ using std::deque;
|
||||
|
||||
#endif // TEST_EXTENSIONS
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
#ifdef TEST_EXTENSIONS
|
||||
deque_tests::deque_hash_integer_tests();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
#include "hash_float_test.hpp"
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
std::cerr<<"Compiler: "<<BOOST_COMPILER<<"\n";
|
||||
std::cerr<<"Platform: "<<BOOST_PLATFORM<<"\n";
|
||||
@@ -14,5 +14,5 @@ int main()
|
||||
float_tests("float", (float*) 0);
|
||||
float_tests("double", (double*) 0);
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# include <boost/functional/hash.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <boost/limits.hpp>
|
||||
@@ -29,12 +29,12 @@ void float_tests(char const* name, T* = 0)
|
||||
std::cerr<<"\n"
|
||||
<<"Testing " BOOST_STRINGIZE(HASH_NAMESPACE) "::hash<"<<name<<">\n"
|
||||
<<"\n"
|
||||
<<"std::numeric_limits<T>::digits = "
|
||||
<<std::numeric_limits<T>::digits<<"\n"
|
||||
<<"std::numeric_limits<int>::digits = "
|
||||
<<std::numeric_limits<int>::digits<<"\n"
|
||||
<<"std::numeric_limits<std::size_t>::digits = "
|
||||
<<std::numeric_limits<std::size_t>::digits<<"\n"
|
||||
<<"boost::hash_detail::limits<T>::digits = "
|
||||
<<boost::hash_detail::limits<T>::digits<<"\n"
|
||||
<<"boost::hash_detail::limits<int>::digits = "
|
||||
<<boost::hash_detail::limits<int>::digits<<"\n"
|
||||
<<"boost::hash_detail::limits<std::size_t>::digits = "
|
||||
<<boost::hash_detail::limits<std::size_t>::digits<<"\n"
|
||||
<<"\n"
|
||||
;
|
||||
|
||||
@@ -43,11 +43,11 @@ void float_tests(char const* name, T* = 0)
|
||||
T zero = 0;
|
||||
T minus_zero = (T) -1 * zero;
|
||||
|
||||
BOOST_TEST(zero == minus_zero);
|
||||
BOOST_TEST(x1(zero) == x1(minus_zero));
|
||||
BOOST_CHECK(zero == minus_zero);
|
||||
BOOST_CHECK(x1(zero) == x1(minus_zero));
|
||||
|
||||
BOOST_TEST(x1(zero) == HASH_NAMESPACE::hash_value(zero));
|
||||
BOOST_TEST(x1(minus_zero) == HASH_NAMESPACE::hash_value(minus_zero));
|
||||
BOOST_CHECK(x1(zero) == HASH_NAMESPACE::hash_value(zero));
|
||||
BOOST_CHECK(x1(minus_zero) == HASH_NAMESPACE::hash_value(minus_zero));
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -55,33 +55,33 @@ void float_tests(char const* name, T* = 0)
|
||||
#if defined(__BORLANDC__)
|
||||
std::cerr<<"Not running infinity checks on Borland, as it causes it to crash.\n";
|
||||
#else
|
||||
if(std::numeric_limits<T>::has_infinity) {
|
||||
if(boost::hash_detail::limits<T>::has_infinity) {
|
||||
T infinity = -log(zero);
|
||||
T infinity2 = (T) 1. / zero;
|
||||
T infinity3 = (T) -1. / minus_zero;
|
||||
T infinity4 = std::numeric_limits<T>::infinity();
|
||||
T infinity4 = boost::hash_detail::limits<T>::infinity();
|
||||
|
||||
T minus_infinity = log(zero);
|
||||
T minus_infinity2 = (T) -1. / zero;
|
||||
T minus_infinity3 = (T) 1. / minus_zero;
|
||||
|
||||
BOOST_TEST(x1(infinity) == HASH_NAMESPACE::hash_value(infinity));
|
||||
BOOST_TEST(x1(minus_infinity)
|
||||
BOOST_CHECK(x1(infinity) == HASH_NAMESPACE::hash_value(infinity));
|
||||
BOOST_CHECK(x1(minus_infinity)
|
||||
== HASH_NAMESPACE::hash_value(minus_infinity));
|
||||
|
||||
if(infinity == infinity2)
|
||||
BOOST_TEST(x1(infinity) == x1(infinity2));
|
||||
BOOST_CHECK(x1(infinity) == x1(infinity2));
|
||||
if(infinity == infinity3)
|
||||
BOOST_TEST(x1(infinity) == x1(infinity3));
|
||||
BOOST_CHECK(x1(infinity) == x1(infinity3));
|
||||
if(infinity == infinity4)
|
||||
BOOST_TEST(x1(infinity) == x1(infinity4));
|
||||
BOOST_CHECK(x1(infinity) == x1(infinity4));
|
||||
|
||||
if(minus_infinity == minus_infinity2)
|
||||
BOOST_TEST(x1(minus_infinity) == x1(minus_infinity2));
|
||||
BOOST_CHECK(x1(minus_infinity) == x1(minus_infinity2));
|
||||
if(minus_infinity == minus_infinity3)
|
||||
BOOST_TEST(x1(minus_infinity) == x1(minus_infinity3));
|
||||
BOOST_CHECK(x1(minus_infinity) == x1(minus_infinity3));
|
||||
|
||||
BOOST_TEST(infinity != minus_infinity);
|
||||
BOOST_CHECK(infinity != minus_infinity);
|
||||
|
||||
if(x1(infinity) == x1(minus_infinity)) {
|
||||
std::cerr<<"x1(infinity) == x1(-infinity) == "<<x1(infinity)<<"\n";
|
||||
@@ -89,46 +89,46 @@ void float_tests(char const* name, T* = 0)
|
||||
|
||||
// This should really be 'has_denorm == denorm_present' but some
|
||||
// compilers don't have 'denorm_present'. See also a later use.
|
||||
if(std::numeric_limits<T>::has_denorm) {
|
||||
if(x1(std::numeric_limits<T>::denorm_min()) == x1(infinity)) {
|
||||
if(boost::hash_detail::limits<T>::has_denorm) {
|
||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) == x1(infinity)) {
|
||||
std::cerr<<"x1(denorm_min) == x1(infinity) == "<<x1(infinity)<<"\n";
|
||||
}
|
||||
if(x1(std::numeric_limits<T>::denorm_min()) == x1(minus_infinity)) {
|
||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) == x1(minus_infinity)) {
|
||||
std::cerr<<"x1(denorm_min) == x1(-infinity) == "<<x1(minus_infinity)<<"\n";
|
||||
}
|
||||
}
|
||||
if(std::numeric_limits<T>::has_quiet_NaN) {
|
||||
if(x1(std::numeric_limits<T>::quiet_NaN()) == x1(infinity)) {
|
||||
if(boost::hash_detail::limits<T>::has_quiet_NaN) {
|
||||
if(x1(boost::hash_detail::limits<T>::quiet_NaN()) == x1(infinity)) {
|
||||
std::cerr<<"x1(quiet_NaN) == x1(infinity) == "<<x1(infinity)<<"\n";
|
||||
}
|
||||
if(x1(std::numeric_limits<T>::quiet_NaN()) == x1(minus_infinity)) {
|
||||
if(x1(boost::hash_detail::limits<T>::quiet_NaN()) == x1(minus_infinity)) {
|
||||
std::cerr<<"x1(quiet_NaN) == x1(-infinity) == "<<x1(minus_infinity)<<"\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
T max = (std::numeric_limits<T>::max)();
|
||||
T max = (boost::hash_detail::limits<T>::max)();
|
||||
T half_max = max / 2;
|
||||
T quarter_max = max / 4;
|
||||
T three_quarter_max = max - quarter_max;
|
||||
|
||||
BOOST_TEST(x1(max) == HASH_NAMESPACE::hash_value(max));
|
||||
BOOST_TEST(x1(half_max) == HASH_NAMESPACE::hash_value(half_max));
|
||||
BOOST_TEST(x1(quarter_max) == HASH_NAMESPACE::hash_value(quarter_max));
|
||||
BOOST_TEST(x1(three_quarter_max) == HASH_NAMESPACE::hash_value(three_quarter_max));
|
||||
BOOST_CHECK(x1(max) == HASH_NAMESPACE::hash_value(max));
|
||||
BOOST_CHECK(x1(half_max) == HASH_NAMESPACE::hash_value(half_max));
|
||||
BOOST_CHECK(x1(quarter_max) == HASH_NAMESPACE::hash_value(quarter_max));
|
||||
BOOST_CHECK(x1(three_quarter_max) == HASH_NAMESPACE::hash_value(three_quarter_max));
|
||||
|
||||
// The '!=' tests could legitimately fail, but with my hash it indicates a bug.
|
||||
BOOST_TEST(x1(max) == x1(max));
|
||||
BOOST_TEST(x1(max) != x1(quarter_max));
|
||||
BOOST_TEST(x1(max) != x1(half_max));
|
||||
BOOST_TEST(x1(max) != x1(three_quarter_max));
|
||||
BOOST_TEST(x1(quarter_max) == x1(quarter_max));
|
||||
BOOST_TEST(x1(quarter_max) != x1(half_max));
|
||||
BOOST_TEST(x1(quarter_max) != x1(three_quarter_max));
|
||||
BOOST_TEST(x1(half_max) == x1(half_max));
|
||||
BOOST_TEST(x1(half_max) != x1(three_quarter_max));
|
||||
BOOST_TEST(x1(three_quarter_max) == x1(three_quarter_max));
|
||||
BOOST_CHECK(x1(max) == x1(max));
|
||||
BOOST_CHECK(x1(max) != x1(quarter_max));
|
||||
BOOST_CHECK(x1(max) != x1(half_max));
|
||||
BOOST_CHECK(x1(max) != x1(three_quarter_max));
|
||||
BOOST_CHECK(x1(quarter_max) == x1(quarter_max));
|
||||
BOOST_CHECK(x1(quarter_max) != x1(half_max));
|
||||
BOOST_CHECK(x1(quarter_max) != x1(three_quarter_max));
|
||||
BOOST_CHECK(x1(half_max) == x1(half_max));
|
||||
BOOST_CHECK(x1(half_max) != x1(three_quarter_max));
|
||||
BOOST_CHECK(x1(three_quarter_max) == x1(three_quarter_max));
|
||||
|
||||
// Intel with gcc stdlib sometimes segfaults on calls to asin and acos.
|
||||
#if !((defined(__INTEL_COMPILER) || defined(__ICL) || \
|
||||
@@ -137,55 +137,55 @@ void float_tests(char const* name, T* = 0)
|
||||
T v1 = asin((T) 1);
|
||||
T v2 = acos((T) 0);
|
||||
if(v1 == v2)
|
||||
BOOST_TEST(x1(v1) == x1(v2));
|
||||
BOOST_TEST(x1(v1) == HASH_NAMESPACE::hash_value(v1));
|
||||
BOOST_TEST(x1(v2) == HASH_NAMESPACE::hash_value(v2));
|
||||
BOOST_CHECK(x1(v1) == x1(v2));
|
||||
BOOST_CHECK(x1(v1) == HASH_NAMESPACE::hash_value(v1));
|
||||
BOOST_CHECK(x1(v2) == HASH_NAMESPACE::hash_value(v2));
|
||||
#endif
|
||||
|
||||
BOOST_TEST(x1(std::numeric_limits<T>::epsilon()) ==
|
||||
HASH_NAMESPACE::hash_value(std::numeric_limits<T>::epsilon()));
|
||||
BOOST_CHECK(x1(boost::hash_detail::limits<T>::epsilon()) ==
|
||||
HASH_NAMESPACE::hash_value(boost::hash_detail::limits<T>::epsilon()));
|
||||
|
||||
BOOST_TEST(std::numeric_limits<T>::epsilon() != (T) 0);
|
||||
if(x1(std::numeric_limits<T>::epsilon()) == x1((T) 0))
|
||||
BOOST_CHECK(boost::hash_detail::limits<T>::epsilon() != (T) 0);
|
||||
if(x1(boost::hash_detail::limits<T>::epsilon()) == x1((T) 0))
|
||||
std::cerr<<"x1(epsilon) == x1(0) == "<<x1((T) 0)<<"\n";
|
||||
|
||||
BOOST_TEST(-std::numeric_limits<T>::epsilon() != (T) 0);
|
||||
if(x1(-std::numeric_limits<T>::epsilon()) == x1((T) 0))
|
||||
BOOST_CHECK(-boost::hash_detail::limits<T>::epsilon() != (T) 0);
|
||||
if(x1(-boost::hash_detail::limits<T>::epsilon()) == x1((T) 0))
|
||||
std::cerr<<"x1(-epsilon) == x1(0) == "<<x1((T) 0)<<"\n";
|
||||
|
||||
BOOST_TEST((T) 1 + std::numeric_limits<T>::epsilon() != (T) 1);
|
||||
if(x1((T) 1 + std::numeric_limits<T>::epsilon()) == x1((T) 1))
|
||||
BOOST_CHECK((T) 1 + boost::hash_detail::limits<T>::epsilon() != (T) 1);
|
||||
if(x1((T) 1 + boost::hash_detail::limits<T>::epsilon()) == x1((T) 1))
|
||||
std::cerr<<"x1(1 + epsilon) == x1(1) == "<<x1((T) 1)<<"\n";
|
||||
|
||||
BOOST_TEST((T) 1 - std::numeric_limits<T>::epsilon() != (T) 1);
|
||||
if(x1((T) 1 - std::numeric_limits<T>::epsilon()) == x1((T) 1))
|
||||
BOOST_CHECK((T) 1 - boost::hash_detail::limits<T>::epsilon() != (T) 1);
|
||||
if(x1((T) 1 - boost::hash_detail::limits<T>::epsilon()) == x1((T) 1))
|
||||
std::cerr<<"x1(1 - epsilon) == x1(1) == "<<x1((T) 1)<<"\n";
|
||||
|
||||
BOOST_TEST((T) -1 + std::numeric_limits<T>::epsilon() != (T) -1);
|
||||
if(x1((T) -1 + std::numeric_limits<T>::epsilon()) == x1((T) -1))
|
||||
BOOST_CHECK((T) -1 + boost::hash_detail::limits<T>::epsilon() != (T) -1);
|
||||
if(x1((T) -1 + boost::hash_detail::limits<T>::epsilon()) == x1((T) -1))
|
||||
std::cerr<<"x1(-1 + epsilon) == x1(-1) == "<<x1((T) -1)<<"\n";
|
||||
|
||||
BOOST_TEST((T) -1 - std::numeric_limits<T>::epsilon() != (T) -1);
|
||||
if(x1((T) -1 - std::numeric_limits<T>::epsilon()) == x1((T) -1))
|
||||
BOOST_CHECK((T) -1 - boost::hash_detail::limits<T>::epsilon() != (T) -1);
|
||||
if(x1((T) -1 - boost::hash_detail::limits<T>::epsilon()) == x1((T) -1))
|
||||
std::cerr<<"x1(-1 - epsilon) == x1(-1) == "<<x1((T) -1)<<"\n";
|
||||
|
||||
// As before.
|
||||
if(std::numeric_limits<T>::has_denorm) {
|
||||
if(x1(std::numeric_limits<T>::denorm_min()) == x1(zero)) {
|
||||
if(boost::hash_detail::limits<T>::has_denorm) {
|
||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) == x1(zero)) {
|
||||
std::cerr<<"x1(denorm_min) == x1(zero) == "<<x1(zero)<<"\n";
|
||||
}
|
||||
#if !BOOST_WORKAROUND(__DECCXX_VER,<70190006)
|
||||
// The Tru64/CXX standard library prior to 7.1 contains a bug in the
|
||||
// specialization of std::numeric_limits::denorm_min() for long
|
||||
// specialization of boost::hash_detail::limits::denorm_min() for long
|
||||
// doubles which causes this test to fail.
|
||||
if(x1(std::numeric_limits<T>::denorm_min()) !=
|
||||
HASH_NAMESPACE::hash_value(std::numeric_limits<T>::denorm_min()))
|
||||
if(x1(boost::hash_detail::limits<T>::denorm_min()) !=
|
||||
HASH_NAMESPACE::hash_value(boost::hash_detail::limits<T>::denorm_min()))
|
||||
{
|
||||
std::cerr<<"x1(std::numeric_limits<T>::denorm_min()) = "
|
||||
<< x1(std::numeric_limits<T>::denorm_min())
|
||||
<< "\nhash_value(std::numeric_limits<T>::denorm_min()) = "
|
||||
std::cerr<<"x1(boost::hash_detail::limits<T>::denorm_min()) = "
|
||||
<< x1(boost::hash_detail::limits<T>::denorm_min())
|
||||
<< "\nhash_value(boost::hash_detail::limits<T>::denorm_min()) = "
|
||||
<< HASH_NAMESPACE::hash_value(
|
||||
std::numeric_limits<T>::denorm_min())
|
||||
boost::hash_detail::limits<T>::denorm_min())
|
||||
<< "\nx1(0) = "<<x1(0)<<"\n";
|
||||
}
|
||||
#endif
|
||||
@@ -193,12 +193,12 @@ void float_tests(char const* name, T* = 0)
|
||||
|
||||
// NaN also causes borland to crash.
|
||||
#if !defined(__BORLANDC__)
|
||||
if(std::numeric_limits<T>::has_quiet_NaN) {
|
||||
if(x1(std::numeric_limits<T>::quiet_NaN()) == x1(1.0)) {
|
||||
if(boost::hash_detail::limits<T>::has_quiet_NaN) {
|
||||
if(x1(boost::hash_detail::limits<T>::quiet_NaN()) == x1(1.0)) {
|
||||
std::cerr<<"x1(quiet_NaN) == x1(1.0) == "<<x1(1.0)<<"\n";
|
||||
}
|
||||
BOOST_TEST(x1(std::numeric_limits<T>::quiet_NaN()) ==
|
||||
HASH_NAMESPACE::hash_value(std::numeric_limits<T>::quiet_NaN()));
|
||||
BOOST_CHECK(x1(boost::hash_detail::limits<T>::quiet_NaN()) ==
|
||||
HASH_NAMESPACE::hash_value(boost::hash_detail::limits<T>::quiet_NaN()));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2006-2007 Daniel James.
|
||||
// Copyright 2006-2008 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)
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace boost
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#ifdef TEST_EXTENSIONS
|
||||
|
||||
@@ -61,13 +61,13 @@ namespace boost
|
||||
void custom_tests()
|
||||
{
|
||||
HASH_NAMESPACE::hash<test::custom<int> > custom_hasher;
|
||||
BOOST_TEST(custom_hasher(10) == 100u);
|
||||
BOOST_CHECK(custom_hasher(10) == 100u);
|
||||
test::custom<int> x(55);
|
||||
BOOST_TEST(custom_hasher(x) == 550u);
|
||||
BOOST_CHECK(custom_hasher(x) == 550u);
|
||||
|
||||
{
|
||||
using namespace HASH_NAMESPACE;
|
||||
BOOST_TEST(custom_hasher(x) == hash_value(x));
|
||||
BOOST_CHECK(custom_hasher(x) == hash_value(x));
|
||||
}
|
||||
|
||||
std::vector<test::custom<int> > custom_vector;
|
||||
@@ -85,17 +85,17 @@ void custom_tests()
|
||||
HASH_NAMESPACE::hash_combine(seed2, 250u);
|
||||
HASH_NAMESPACE::hash_combine(seed2, 350u);
|
||||
|
||||
BOOST_TEST(seed ==
|
||||
BOOST_CHECK(seed ==
|
||||
HASH_NAMESPACE::hash_range(custom_vector.begin(), custom_vector.end()));
|
||||
BOOST_TEST(seed == seed2);
|
||||
BOOST_CHECK(seed == seed2);
|
||||
}
|
||||
|
||||
#endif // TEST_EXTENSIONS
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
#ifdef TEST_EXTENSIONS
|
||||
custom_tests();
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# include <boost/functional/hash.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
@@ -32,31 +32,31 @@ void function_pointer_tests()
|
||||
HASH_NAMESPACE::hash<void(*)()> hasher_void;
|
||||
HASH_NAMESPACE::hash<int(*)(int)> hasher_int;
|
||||
|
||||
BOOST_TEST(&void_func1 != &void_func2);
|
||||
BOOST_TEST(&int_func1 != &int_func2);
|
||||
BOOST_CHECK(&void_func1 != &void_func2);
|
||||
BOOST_CHECK(&int_func1 != &int_func2);
|
||||
|
||||
BOOST_TEST(hasher_void(0) == hasher_void(0));
|
||||
BOOST_TEST(hasher_void(&void_func1) == hasher_void(&void_func1));
|
||||
BOOST_TEST(hasher_void(&void_func1) != hasher_void(&void_func2));
|
||||
BOOST_TEST(hasher_void(&void_func1) != hasher_void(0));
|
||||
BOOST_TEST(hasher_int(0) == hasher_int(0));
|
||||
BOOST_TEST(hasher_int(&int_func1) == hasher_int(&int_func1));
|
||||
BOOST_TEST(hasher_int(&int_func1) != hasher_int(&int_func2));
|
||||
BOOST_TEST(hasher_int(&int_func1) != hasher_int(0));
|
||||
BOOST_CHECK(hasher_void(0) == hasher_void(0));
|
||||
BOOST_CHECK(hasher_void(&void_func1) == hasher_void(&void_func1));
|
||||
BOOST_CHECK(hasher_void(&void_func1) != hasher_void(&void_func2));
|
||||
BOOST_CHECK(hasher_void(&void_func1) != hasher_void(0));
|
||||
BOOST_CHECK(hasher_int(0) == hasher_int(0));
|
||||
BOOST_CHECK(hasher_int(&int_func1) == hasher_int(&int_func1));
|
||||
BOOST_CHECK(hasher_int(&int_func1) != hasher_int(&int_func2));
|
||||
BOOST_CHECK(hasher_int(&int_func1) != hasher_int(0));
|
||||
#if defined(TEST_EXTENSIONS)
|
||||
BOOST_TEST(hasher_void(&void_func1)
|
||||
BOOST_CHECK(hasher_void(&void_func1)
|
||||
== HASH_NAMESPACE::hash_value(&void_func1));
|
||||
BOOST_TEST(hasher_int(&int_func1)
|
||||
BOOST_CHECK(hasher_int(&int_func1)
|
||||
== HASH_NAMESPACE::hash_value(&int_func1));
|
||||
|
||||
// This isn't specified in Peter's proposal:
|
||||
BOOST_TEST(hasher_void(0) == 0);
|
||||
BOOST_CHECK(hasher_void(0) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
function_pointer_tests();
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2006-2007 Daniel James.
|
||||
// Copyright 2006-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2006-2007 Daniel James.
|
||||
// Copyright 2006-2008 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)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "./hash_fwd_test.hpp"
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#if defined(TEST_EXTENSIONS) && !defined(TEST_STD_INCLUDES)
|
||||
|
||||
@@ -24,8 +24,8 @@ void fwd_test1()
|
||||
HASH_NAMESPACE::hash<test::test_type1<int> > hasher_test_int;
|
||||
HASH_NAMESPACE::hash<test::test_type1<std::string> > hasher_test_string;
|
||||
|
||||
BOOST_TEST(hasher_int(5) == hasher_test_int(x));
|
||||
BOOST_TEST(hasher_string("Test") == hasher_test_string(y));
|
||||
BOOST_CHECK(hasher_int(5) == hasher_test_int(x));
|
||||
BOOST_CHECK(hasher_string("Test") == hasher_test_string(y));
|
||||
}
|
||||
|
||||
void fwd_test2()
|
||||
@@ -44,8 +44,8 @@ void fwd_test2()
|
||||
HASH_NAMESPACE::hash<test::test_type2<int> > hasher_test_int;
|
||||
HASH_NAMESPACE::hash<test::test_type2<std::string> > hasher_test_string;
|
||||
|
||||
BOOST_TEST(seed1 == hasher_test_int(x));
|
||||
BOOST_TEST(seed2 == hasher_test_string(y));
|
||||
BOOST_CHECK(seed1 == hasher_test_int(x));
|
||||
BOOST_CHECK(seed2 == hasher_test_string(y));
|
||||
}
|
||||
|
||||
void fwd_test3()
|
||||
@@ -75,19 +75,19 @@ void fwd_test3()
|
||||
HASH_NAMESPACE::hash<test::test_type3<int> > hasher_test_int;
|
||||
HASH_NAMESPACE::hash<test::test_type3<std::string> > hasher_test_string;
|
||||
|
||||
BOOST_TEST(seed1 == hasher_test_int(x));
|
||||
BOOST_TEST(seed2 == hasher_test_string(y));
|
||||
BOOST_CHECK(seed1 == hasher_test_int(x));
|
||||
BOOST_CHECK(seed2 == hasher_test_string(y));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
#ifdef TEST_EXTENSIONS
|
||||
fwd_test1();
|
||||
fwd_test2();
|
||||
fwd_test3();
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2006-2007 Daniel James.
|
||||
// Copyright 2006-2008 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)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "./hash_fwd_test.hpp"
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
template <class T> void unused(T const&) {}
|
||||
|
||||
@@ -31,9 +31,9 @@ void fwd_test()
|
||||
}
|
||||
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
fwd_test();
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2006-2007 Daniel James.
|
||||
// Copyright 2006-2008 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)
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace boost
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#ifdef TEST_EXTENSIONS
|
||||
|
||||
@@ -59,13 +59,13 @@ namespace boost
|
||||
void custom_tests()
|
||||
{
|
||||
HASH_NAMESPACE::hash<custom> custom_hasher;
|
||||
BOOST_TEST(custom_hasher(10) == 100u);
|
||||
BOOST_CHECK(custom_hasher(10) == 100u);
|
||||
custom x(55);
|
||||
BOOST_TEST(custom_hasher(x) == 550u);
|
||||
BOOST_CHECK(custom_hasher(x) == 550u);
|
||||
|
||||
{
|
||||
using namespace HASH_NAMESPACE;
|
||||
BOOST_TEST(custom_hasher(x) == hash_value(x));
|
||||
BOOST_CHECK(custom_hasher(x) == hash_value(x));
|
||||
}
|
||||
|
||||
std::vector<custom> custom_vector;
|
||||
@@ -83,19 +83,19 @@ void custom_tests()
|
||||
HASH_NAMESPACE::hash_combine(seed2, 250u);
|
||||
HASH_NAMESPACE::hash_combine(seed2, 350u);
|
||||
|
||||
BOOST_TEST(seed ==
|
||||
BOOST_CHECK(seed ==
|
||||
HASH_NAMESPACE::hash_range(custom_vector.begin(), custom_vector.end()));
|
||||
BOOST_TEST(seed == seed2);
|
||||
BOOST_CHECK(seed == seed2);
|
||||
}
|
||||
|
||||
#endif // TEST_EXTENSIONS
|
||||
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
#ifdef TEST_EXTENSIONS
|
||||
custom_tests();
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#ifdef TEST_EXTENSIONS
|
||||
|
||||
@@ -25,11 +25,11 @@ using std::list;
|
||||
|
||||
#endif // TEST_EXTENSIONS
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
#ifdef TEST_EXTENSIONS
|
||||
list_tests::list_hash_integer_tests();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
#include "hash_float_test.hpp"
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
std::cerr<<"Compiler: "<<BOOST_COMPILER<<"\n";
|
||||
std::cerr<<"Platform: "<<BOOST_PLATFORM<<"\n";
|
||||
@@ -13,5 +13,5 @@ int main()
|
||||
|
||||
float_tests("long double", (long double*) 0);
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <map>
|
||||
|
||||
@@ -29,12 +29,12 @@ using std::multimap;
|
||||
|
||||
#endif // TEST_EXTENSTIONS
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
#ifdef TEST_EXTENSIONS
|
||||
map_tests::map_hash_integer_tests();
|
||||
multimap_tests::multimap_hash_integer_tests();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -38,17 +38,17 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
||||
HASH_NAMESPACE::hash<T> hasher;
|
||||
|
||||
for(int i2 = 0; i2 < number_of_containers; ++i2) {
|
||||
BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2]));
|
||||
BOOST_CHECK(hasher(containers[i2]) == hasher(containers[i2]));
|
||||
|
||||
BOOST_TEST(hasher(containers[i2]) ==
|
||||
BOOST_CHECK(hasher(containers[i2]) ==
|
||||
HASH_NAMESPACE::hash_value(containers[i2]));
|
||||
|
||||
BOOST_TEST(hasher(containers[i2])
|
||||
BOOST_CHECK(hasher(containers[i2])
|
||||
== HASH_NAMESPACE::hash_range(
|
||||
containers[i2].begin(), containers[i2].end()));
|
||||
|
||||
for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) {
|
||||
BOOST_TEST(
|
||||
BOOST_CHECK(
|
||||
(containers[i2] == containers[j2]) ==
|
||||
(hasher(containers[i2]) == hasher(containers[j2]))
|
||||
);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2006-2007 Daniel James.
|
||||
// Copyright 2006-2008 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)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
HASH_NAMESPACE::hash< int[10] > hasher;
|
||||
return 0;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2006-2007 Daniel James.
|
||||
// Copyright 2006-2008 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)
|
||||
|
||||
@@ -7,11 +7,11 @@
|
||||
#include <boost/functional/hash.hpp>
|
||||
#define BOOST_HASH_NO_EXTENSIONS
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <deque>
|
||||
#include <cassert>
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
std::deque<int> x;
|
||||
|
||||
@@ -19,7 +19,7 @@ int main()
|
||||
x.push_back(2);
|
||||
|
||||
HASH_NAMESPACE::hash<std::deque<int> > hasher;
|
||||
BOOST_TEST(hasher(x) == HASH_NAMESPACE::hash_value(x));
|
||||
BOOST_CHECK(hasher(x) == HASH_NAMESPACE::hash_value(x));
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2006-2007 Daniel James.
|
||||
// Copyright 2006-2008 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)
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
#include <boost/functional/hash.hpp>
|
||||
#undef BOOST_HASH_NO_EXTENSIONS
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <map>
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
std::map<int, int> x;
|
||||
|
||||
@@ -19,7 +19,7 @@ int main()
|
||||
x.insert(std::map<int, int>::value_type(14, -75));
|
||||
|
||||
HASH_NAMESPACE::hash<std::map<int, int> > hasher;
|
||||
BOOST_TEST(hasher(x) == HASH_NAMESPACE::hash_value(x));
|
||||
BOOST_CHECK(hasher(x) == HASH_NAMESPACE::hash_value(x));
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <boost/preprocessor/cat.hpp>
|
||||
#include <boost/limits.hpp>
|
||||
@@ -31,7 +31,7 @@
|
||||
template <class T>
|
||||
void numeric_test(T*)
|
||||
{
|
||||
typedef std::numeric_limits<T> limits;
|
||||
typedef boost::hash_detail::limits<T> limits;
|
||||
|
||||
compile_time_tests((T*) 0);
|
||||
|
||||
@@ -39,27 +39,27 @@ void numeric_test(T*)
|
||||
HASH_NAMESPACE::hash<T> x2;
|
||||
|
||||
T v1 = (T) -5;
|
||||
BOOST_TEST(x1(v1) == x2(v1));
|
||||
BOOST_TEST(x1(T(-5)) == x2(T(-5)));
|
||||
BOOST_TEST(x1(T(0)) == x2(T(0)));
|
||||
BOOST_TEST(x1(T(10)) == x2(T(10)));
|
||||
BOOST_TEST(x1(T(25)) == x2(T(25)));
|
||||
BOOST_TEST(x1(T(5) - T(5)) == x2(T(0)));
|
||||
BOOST_TEST(x1(T(6) + T(4)) == x2(T(10)));
|
||||
BOOST_CHECK(x1(v1) == x2(v1));
|
||||
BOOST_CHECK(x1(T(-5)) == x2(T(-5)));
|
||||
BOOST_CHECK(x1(T(0)) == x2(T(0)));
|
||||
BOOST_CHECK(x1(T(10)) == x2(T(10)));
|
||||
BOOST_CHECK(x1(T(25)) == x2(T(25)));
|
||||
BOOST_CHECK(x1(T(5) - T(5)) == x2(T(0)));
|
||||
BOOST_CHECK(x1(T(6) + T(4)) == x2(T(10)));
|
||||
|
||||
#if defined(TEST_EXTENSIONS)
|
||||
BOOST_TEST(x1(T(-5)) == HASH_NAMESPACE::hash_value(T(-5)));
|
||||
BOOST_TEST(x1(T(0)) == HASH_NAMESPACE::hash_value(T(0)));
|
||||
BOOST_TEST(x1(T(10)) == HASH_NAMESPACE::hash_value(T(10)));
|
||||
BOOST_TEST(x1(T(25)) == HASH_NAMESPACE::hash_value(T(25)));
|
||||
BOOST_CHECK(x1(T(-5)) == HASH_NAMESPACE::hash_value(T(-5)));
|
||||
BOOST_CHECK(x1(T(0)) == HASH_NAMESPACE::hash_value(T(0)));
|
||||
BOOST_CHECK(x1(T(10)) == HASH_NAMESPACE::hash_value(T(10)));
|
||||
BOOST_CHECK(x1(T(25)) == HASH_NAMESPACE::hash_value(T(25)));
|
||||
|
||||
if (limits::is_integer)
|
||||
{
|
||||
if(limits::is_signed || limits::digits <= std::numeric_limits<std::size_t>::digits)
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(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(10)) == (std::size_t)T(10u));
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(T(25)) == (std::size_t)T(25u));
|
||||
if(limits::is_signed || limits::digits <= boost::hash_detail::limits<std::size_t>::digits)
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_value(T(-5)) == (std::size_t)T(-5));
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_value(T(0)) == (std::size_t)T(0u));
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_value(T(10)) == (std::size_t)T(10u));
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_value(T(25)) == (std::size_t)T(25u));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -67,7 +67,7 @@ void numeric_test(T*)
|
||||
template <class T>
|
||||
void limits_test(T*)
|
||||
{
|
||||
typedef std::numeric_limits<T> limits;
|
||||
typedef boost::hash_detail::limits<T> limits;
|
||||
|
||||
if(limits::is_specialized)
|
||||
{
|
||||
@@ -77,18 +77,18 @@ void limits_test(T*)
|
||||
T min_value = (limits::min)();
|
||||
T max_value = (limits::max)();
|
||||
|
||||
BOOST_TEST(x1(min_value) == x2((limits::min)()));
|
||||
BOOST_TEST(x1(max_value) == x2((limits::max)()));
|
||||
BOOST_CHECK(x1(min_value) == x2((limits::min)()));
|
||||
BOOST_CHECK(x1(max_value) == x2((limits::max)()));
|
||||
|
||||
#if defined(TEST_EXTENSIONS)
|
||||
BOOST_TEST(x1(min_value) == HASH_NAMESPACE::hash_value(min_value));
|
||||
BOOST_TEST(x1(max_value) == HASH_NAMESPACE::hash_value(max_value));
|
||||
BOOST_CHECK(x1(min_value) == HASH_NAMESPACE::hash_value(min_value));
|
||||
BOOST_CHECK(x1(max_value) == HASH_NAMESPACE::hash_value(max_value));
|
||||
|
||||
if (limits::is_integer)
|
||||
{
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(min_value)
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_value(min_value)
|
||||
== std::size_t(min_value));
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(max_value)
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_value(max_value)
|
||||
== std::size_t(max_value));
|
||||
}
|
||||
#endif
|
||||
@@ -98,7 +98,7 @@ void limits_test(T*)
|
||||
template <class T>
|
||||
void poor_quality_tests(T*)
|
||||
{
|
||||
typedef std::numeric_limits<T> limits;
|
||||
typedef boost::hash_detail::limits<T> limits;
|
||||
|
||||
HASH_NAMESPACE::hash<T> x1;
|
||||
HASH_NAMESPACE::hash<T> x2;
|
||||
@@ -106,11 +106,11 @@ void poor_quality_tests(T*)
|
||||
// A hash function can legally fail these tests, but it'll not be a good
|
||||
// sign.
|
||||
if(T(1) != T(-1))
|
||||
BOOST_TEST(x1(T(1)) != x2(T(-1)));
|
||||
BOOST_CHECK(x1(T(1)) != x2(T(-1)));
|
||||
if(T(1) != T(2))
|
||||
BOOST_TEST(x1(T(1)) != x2(T(2)));
|
||||
BOOST_CHECK(x1(T(1)) != x2(T(2)));
|
||||
if((limits::max)() != (limits::max)() - 1)
|
||||
BOOST_TEST(x1((limits::max)()) != x2((limits::max)() - 1));
|
||||
BOOST_CHECK(x1((limits::max)()) != x2((limits::max)() - 1));
|
||||
}
|
||||
|
||||
void bool_test()
|
||||
@@ -118,10 +118,10 @@ 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));
|
||||
BOOST_CHECK(x1(true) == x2(true));
|
||||
BOOST_CHECK(x1(false) == x2(false));
|
||||
BOOST_CHECK(x1(true) != x2(false));
|
||||
BOOST_CHECK(x1(false) != x2(true));
|
||||
}
|
||||
|
||||
#define NUMERIC_TEST(type, name) \
|
||||
@@ -134,7 +134,7 @@ void bool_test()
|
||||
numeric_test((type*) 0); \
|
||||
poor_quality_tests((type*) 0);
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
NUMERIC_TEST(char, char)
|
||||
NUMERIC_TEST(signed char, schar)
|
||||
@@ -150,8 +150,8 @@ int main()
|
||||
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)
|
||||
NUMERIC_TEST_NO_LIMITS(boost::long_long_type, long_long)
|
||||
NUMERIC_TEST_NO_LIMITS(boost::ulong_long_type, ulong_long)
|
||||
#endif
|
||||
|
||||
NUMERIC_TEST(float, float)
|
||||
@@ -159,7 +159,7 @@ int main()
|
||||
|
||||
bool_test();
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(BOOST_MSVC)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# include <boost/functional/hash.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
@@ -30,20 +30,20 @@ void pointer_tests()
|
||||
int int1;
|
||||
int int2;
|
||||
|
||||
BOOST_TEST(x1(0) == x2(0));
|
||||
BOOST_TEST(x1(&int1) == x2(&int1));
|
||||
BOOST_TEST(x1(&int2) == x2(&int2));
|
||||
BOOST_CHECK(x1(0) == x2(0));
|
||||
BOOST_CHECK(x1(&int1) == x2(&int1));
|
||||
BOOST_CHECK(x1(&int2) == x2(&int2));
|
||||
#if defined(TEST_EXTENSIONS)
|
||||
BOOST_TEST(x1(&int1) == HASH_NAMESPACE::hash_value(&int1));
|
||||
BOOST_TEST(x1(&int2) == HASH_NAMESPACE::hash_value(&int2));
|
||||
BOOST_CHECK(x1(&int1) == HASH_NAMESPACE::hash_value(&int1));
|
||||
BOOST_CHECK(x1(&int2) == HASH_NAMESPACE::hash_value(&int2));
|
||||
|
||||
// This isn't specified in Peter's proposal:
|
||||
BOOST_TEST(x1(0) == 0);
|
||||
BOOST_CHECK(x1(0) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
pointer_tests();
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#ifdef TEST_EXTENSIONS
|
||||
|
||||
@@ -41,45 +41,45 @@ void hash_range_tests()
|
||||
std::vector<int> x;
|
||||
|
||||
std::size_t x_seed = 0;
|
||||
BOOST_TEST(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
BOOST_CHECK(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_range(empty.begin(), empty.end())
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_range(empty.begin(), empty.end())
|
||||
== HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_range(empty.begin(), empty.end())
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_range(empty.begin(), empty.end())
|
||||
!= HASH_NAMESPACE::hash_range(values1.begin(), values1.end()));
|
||||
|
||||
x.push_back(10);
|
||||
HASH_NAMESPACE::hash_combine(x_seed, 10);
|
||||
BOOST_TEST(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
BOOST_CHECK(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_range(empty.begin(), empty.end())
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_range(empty.begin(), empty.end())
|
||||
!= HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_range(values2.begin(), values2.end())
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_range(values2.begin(), values2.end())
|
||||
== HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
|
||||
x.push_back(20);
|
||||
HASH_NAMESPACE::hash_combine(x_seed, 20);
|
||||
BOOST_TEST(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
BOOST_CHECK(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_range(empty.begin(), empty.end())
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_range(empty.begin(), empty.end())
|
||||
!= HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_range(values2.begin(), values2.end())
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_range(values2.begin(), values2.end())
|
||||
!= HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_range(values3.begin(), values3.end())
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_range(values3.begin(), values3.end())
|
||||
== HASH_NAMESPACE::hash_range(x.begin(), x.end()));
|
||||
|
||||
std::size_t seed = HASH_NAMESPACE::hash_range(values3.begin(), values3.end());
|
||||
HASH_NAMESPACE::hash_range(seed, values4.begin(), values4.end());
|
||||
HASH_NAMESPACE::hash_range(seed, x.begin(), x.end());
|
||||
BOOST_TEST(seed == HASH_NAMESPACE::hash_range(values5.begin(), values5.end()));
|
||||
BOOST_CHECK(seed == HASH_NAMESPACE::hash_range(values5.begin(), values5.end()));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
hash_range_tests();
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -41,17 +41,17 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
||||
HASH_NAMESPACE::hash<T> hasher;
|
||||
|
||||
for(int i2 = 0; i2 < number_of_containers; ++i2) {
|
||||
BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2]));
|
||||
BOOST_CHECK(hasher(containers[i2]) == hasher(containers[i2]));
|
||||
|
||||
BOOST_TEST(hasher(containers[i2]) ==
|
||||
BOOST_CHECK(hasher(containers[i2]) ==
|
||||
HASH_NAMESPACE::hash_value(containers[i2]));
|
||||
|
||||
BOOST_TEST(hasher(containers[i2])
|
||||
BOOST_CHECK(hasher(containers[i2])
|
||||
== HASH_NAMESPACE::hash_range(
|
||||
containers[i2].begin(), containers[i2].end()));
|
||||
|
||||
for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) {
|
||||
BOOST_TEST(
|
||||
BOOST_CHECK(
|
||||
(containers[i2] == containers[j2]) ==
|
||||
(hasher(containers[i2]) == hasher(containers[j2]))
|
||||
);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#ifdef TEST_EXTENSIONS
|
||||
|
||||
@@ -29,12 +29,12 @@ using std::multiset;
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
#ifdef TEST_EXTENSIONS
|
||||
set_tests::set_hash_integer_tests();
|
||||
multiset_tests::multiset_hash_integer_tests();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -44,17 +44,17 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests)
|
||||
HASH_NAMESPACE::hash<T> hasher;
|
||||
|
||||
for(int i2 = 0; i2 < number_of_containers; ++i2) {
|
||||
BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2]));
|
||||
BOOST_CHECK(hasher(containers[i2]) == hasher(containers[i2]));
|
||||
|
||||
BOOST_TEST(hasher(containers[i2]) ==
|
||||
BOOST_CHECK(hasher(containers[i2]) ==
|
||||
HASH_NAMESPACE::hash_value(containers[i2]));
|
||||
|
||||
BOOST_TEST(hasher(containers[i2])
|
||||
BOOST_CHECK(hasher(containers[i2])
|
||||
== HASH_NAMESPACE::hash_range(
|
||||
containers[i2].begin(), containers[i2].end()));
|
||||
|
||||
for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) {
|
||||
BOOST_TEST(
|
||||
BOOST_CHECK(
|
||||
(containers[i2] == containers[j2]) ==
|
||||
(hasher(containers[i2]) == hasher(containers[j2]))
|
||||
);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# include <boost/functional/hash.hpp>
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#include <boost/limits.hpp>
|
||||
#include <boost/mpl/assert.hpp>
|
||||
@@ -27,18 +27,18 @@ void string_tests()
|
||||
HASH_NAMESPACE::hash<std::string> x1;
|
||||
HASH_NAMESPACE::hash<std::string> x2;
|
||||
|
||||
BOOST_TEST(x1("Hello") == x2(std::string("Hel") + "lo"));
|
||||
BOOST_TEST(x1("") == x2(std::string()));
|
||||
BOOST_CHECK(x1("Hello") == x2(std::string("Hel") + "lo"));
|
||||
BOOST_CHECK(x1("") == x2(std::string()));
|
||||
|
||||
#if defined(TEST_EXTENSIONS)
|
||||
std::string value1;
|
||||
std::string value2("Hello");
|
||||
|
||||
BOOST_TEST(x1(value1) == HASH_NAMESPACE::hash_value(value1));
|
||||
BOOST_TEST(x1(value2) == HASH_NAMESPACE::hash_value(value2));
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(value1) ==
|
||||
BOOST_CHECK(x1(value1) == HASH_NAMESPACE::hash_value(value1));
|
||||
BOOST_CHECK(x1(value2) == HASH_NAMESPACE::hash_value(value2));
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_value(value1) ==
|
||||
HASH_NAMESPACE::hash_range(value1.begin(), value1.end()));
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(value2) ==
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_value(value2) ==
|
||||
HASH_NAMESPACE::hash_range(value2.begin(), value2.end()));
|
||||
#endif
|
||||
}
|
||||
@@ -51,28 +51,28 @@ void wstring_tests()
|
||||
HASH_NAMESPACE::hash<std::wstring> x1;
|
||||
HASH_NAMESPACE::hash<std::wstring> x2;
|
||||
|
||||
BOOST_TEST(x1(L"Hello") == x2(std::wstring(L"Hel") + L"lo"));
|
||||
BOOST_TEST(x1(L"") == x2(std::wstring()));
|
||||
BOOST_CHECK(x1(L"Hello") == x2(std::wstring(L"Hel") + L"lo"));
|
||||
BOOST_CHECK(x1(L"") == x2(std::wstring()));
|
||||
|
||||
#if defined(TEST_EXTENSIONS)
|
||||
std::wstring value1;
|
||||
std::wstring value2(L"Hello");
|
||||
|
||||
BOOST_TEST(x1(value1) == HASH_NAMESPACE::hash_value(value1));
|
||||
BOOST_TEST(x1(value2) == HASH_NAMESPACE::hash_value(value2));
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(value1) ==
|
||||
BOOST_CHECK(x1(value1) == HASH_NAMESPACE::hash_value(value1));
|
||||
BOOST_CHECK(x1(value2) == HASH_NAMESPACE::hash_value(value2));
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_value(value1) ==
|
||||
HASH_NAMESPACE::hash_range(value1.begin(), value1.end()));
|
||||
BOOST_TEST(HASH_NAMESPACE::hash_value(value2) ==
|
||||
BOOST_CHECK(HASH_NAMESPACE::hash_value(value2) ==
|
||||
HASH_NAMESPACE::hash_range(value2.begin(), value2.end()));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
string_tests();
|
||||
#if !defined(BOOST_NO_STD_WSTRING)
|
||||
wstring_tests();
|
||||
#endif
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#ifdef TEST_EXTENSIONS
|
||||
|
||||
@@ -37,9 +37,9 @@ void array_int_test()
|
||||
int array3[2] = {2, 3};
|
||||
HASH_NAMESPACE::hash<int[2]> hasher3;
|
||||
|
||||
BOOST_TEST(hasher1(array1) == HASH_NAMESPACE::hash_value(array1));
|
||||
BOOST_TEST(hasher2(array2) == HASH_NAMESPACE::hash_value(array2));
|
||||
BOOST_TEST(hasher3(array3) == HASH_NAMESPACE::hash_value(array3));
|
||||
BOOST_CHECK(hasher1(array1) == HASH_NAMESPACE::hash_value(array1));
|
||||
BOOST_CHECK(hasher2(array2) == HASH_NAMESPACE::hash_value(array2));
|
||||
BOOST_CHECK(hasher3(array3) == HASH_NAMESPACE::hash_value(array3));
|
||||
}
|
||||
|
||||
void two_dimensional_array_test()
|
||||
@@ -47,18 +47,18 @@ void two_dimensional_array_test()
|
||||
int array[3][2] = {{-5, 6}, {7, -3}, {26, 1}};
|
||||
HASH_NAMESPACE::hash<int[3][2]> hasher;
|
||||
|
||||
BOOST_TEST(hasher(array) == HASH_NAMESPACE::hash_value(array));
|
||||
BOOST_CHECK(hasher(array) == HASH_NAMESPACE::hash_value(array));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
#ifdef TEST_EXTENSIONS
|
||||
array_int_test();
|
||||
two_dimensional_array_test();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
|
||||
#ifdef TEST_EXTENSIONS
|
||||
|
||||
@@ -25,11 +25,11 @@ using std::vector;
|
||||
|
||||
#endif // TEST_EXTENSIONS
|
||||
|
||||
int main()
|
||||
int test_main(int, char**)
|
||||
{
|
||||
#ifdef TEST_EXTENSIONS
|
||||
vector_tests::vector_hash_integer_tests();
|
||||
#endif
|
||||
|
||||
return boost::report_errors();
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,17 +1,17 @@
|
||||
|
||||
// Copyright 2006-2007 Daniel James.
|
||||
// Copyright 2006-2008 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)
|
||||
|
||||
#define HASH_NAMESPACE boost
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <vector>
|
||||
|
||||
int f(std::size_t hash1, int* x1) {
|
||||
// Check that HASH_NAMESPACE::hash<int*> works in both files.
|
||||
HASH_NAMESPACE::hash<int*> ptr_hasher;
|
||||
BOOST_TEST(hash1 == ptr_hasher(x1));
|
||||
BOOST_CHECK(hash1 == ptr_hasher(x1));
|
||||
|
||||
// Check that std::vector<std::size_t> is avaiable in this file.
|
||||
std::vector<std::size_t> x;
|
||||
|
@@ -1,18 +1,19 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
#define HASH_NAMESPACE boost
|
||||
#define BOOST_HASH_NO_EXTENSIONS
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
extern int f(std::size_t, int*);
|
||||
|
||||
int main() {
|
||||
int test_main(int, char**) {
|
||||
HASH_NAMESPACE::hash<int*> ptr_hasher;
|
||||
int x = 55;
|
||||
BOOST_TEST(!f(ptr_hasher(&x), &x));
|
||||
return boost::report_errors();
|
||||
|
||||
BOOST_ASSERT(!f(ptr_hasher(&x), &x));
|
||||
return 0;
|
||||
}
|
||||
|
@@ -1,9 +1,9 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
extern int f();
|
||||
int main() { return f(); }
|
||||
int main(int, char**) { return f(); }
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
// STLport
|
||||
#elif defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION)
|
||||
// _fpclass and fpclassify aren't good enough on STLport.
|
||||
// fpclassify aren't good enough on STLport.
|
||||
|
||||
// GNU libstdc++ 3
|
||||
#elif defined(__GLIBCPP__) || defined(__GLIBCXX__)
|
||||
@@ -50,19 +50,47 @@
|
||||
// Dinkumware Library, on Visual C++
|
||||
#elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER)
|
||||
|
||||
// Not using _fpclass because it causes a warning about a conversion
|
||||
// from 'long double' to 'double'. Pity.
|
||||
//
|
||||
//# if defined(BOOST_MSVC)
|
||||
//# define BOOST_HASH_USE_FPCLASS
|
||||
//# endif
|
||||
// Not using _fpclass because it is only available for double.
|
||||
|
||||
#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 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)
|
||||
{
|
||||
seed ^= value + (seed<<6) + (seed>>2);
|
||||
@@ -107,29 +135,28 @@ namespace boost
|
||||
// sign with the exponent.
|
||||
if(v < 0) {
|
||||
v = -v;
|
||||
exp += std::numeric_limits<T>::max_exponent -
|
||||
std::numeric_limits<T>::min_exponent;
|
||||
exp += limits<T>::max_exponent -
|
||||
limits<T>::min_exponent;
|
||||
}
|
||||
|
||||
// The result of frexp is always between 0.5 and 1, so its
|
||||
// top bit will always be 1. Subtract by 0.5 to remove that.
|
||||
v -= T(0.5);
|
||||
v = boost::hash_detail::call_ldexp(v,
|
||||
std::numeric_limits<std::size_t>::digits + 1);
|
||||
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::numeric_limits<T>::digits *
|
||||
boost::static_log2<std::numeric_limits<T>::radix>::value
|
||||
- 1)
|
||||
/ std::numeric_limits<std::size_t>::digits;
|
||||
= (limits<T>::digits *
|
||||
boost::static_log2<limits<T>::radix>::value - 1)
|
||||
/ limits<std::size_t>::digits;
|
||||
|
||||
for(std::size_t i = 0; i != length; ++i)
|
||||
{
|
||||
v = boost::hash_detail::call_ldexp(v,
|
||||
std::numeric_limits<std::size_t>::digits);
|
||||
limits<std::size_t>::digits);
|
||||
std::size_t part = static_cast<std::size_t>(v);
|
||||
v -= part;
|
||||
hash_float_combine(seed, part);
|
||||
@@ -160,28 +187,6 @@ namespace boost
|
||||
BOOST_ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
#elif defined(BOOST_HASH_USE_FPCLASS)
|
||||
switch(_fpclass(v)) {
|
||||
case _FPCLASS_NZ:
|
||||
case _FPCLASS_PZ:
|
||||
return 0;
|
||||
case _FPCLASS_PINF:
|
||||
return (std::size_t)(-1);
|
||||
case _FPCLASS_NINF:
|
||||
return (std::size_t)(-2);
|
||||
case _FPCLASS_SNAN:
|
||||
case _FPCLASS_QNAN:
|
||||
return (std::size_t)(-3);
|
||||
case _FPCLASS_NN:
|
||||
case _FPCLASS_ND:
|
||||
return float_hash_impl(v);
|
||||
case _FPCLASS_PD:
|
||||
case _FPCLASS_PN:
|
||||
return float_hash_impl(v);
|
||||
default:
|
||||
BOOST_ASSERT(0);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
return v == 0 ? 0 : float_hash_impl(v);
|
||||
#endif
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -8,3 +8,4 @@
|
||||
// issue 6.18.
|
||||
|
||||
#include <boost/functional/hash/hash.hpp>
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
182
include/boost/functional/hash/extensions.hpp
Normal file
182
include/boost/functional/hash/extensions.hpp
Normal file
@@ -0,0 +1,182 @@
|
||||
|
||||
// Copyright 2005-2008 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,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
@@ -46,8 +46,8 @@ namespace boost
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
std::size_t hash_value(long long);
|
||||
std::size_t hash_value(unsigned long long);
|
||||
std::size_t hash_value(boost::long_long_type);
|
||||
std::size_t hash_value(boost::ulong_long_type);
|
||||
#endif
|
||||
|
||||
#if !BOOST_WORKAROUND(__DMC__, <= 0x848)
|
||||
@@ -195,12 +195,12 @@ namespace boost
|
||||
#endif
|
||||
|
||||
#if defined(BOOST_HAS_LONG_LONG)
|
||||
inline std::size_t hash_value(long long v)
|
||||
inline std::size_t hash_value(boost::long_long_type v)
|
||||
{
|
||||
return hash_detail::hash_value_signed(v);
|
||||
}
|
||||
|
||||
inline std::size_t hash_value(unsigned long long v)
|
||||
inline std::size_t hash_value(boost::ulong_long_type v)
|
||||
{
|
||||
return hash_detail::hash_value_unsigned(v);
|
||||
}
|
||||
@@ -518,176 +518,12 @@ namespace boost
|
||||
}
|
||||
|
||||
#endif // BOOST_FUNCTIONAL_HASH_HASH_HPP
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Include this outside of the include guards in case the file is included
|
||||
// twice - once with BOOST_HASH_NO_EXTENSIONS defined, and then with it
|
||||
// undefined.
|
||||
|
||||
#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)
|
||||
#include <boost/functional/hash/extensions.hpp>
|
||||
#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,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
|
||||
// Copyright 2005-2007 Daniel James.
|
||||
// Copyright 2005-2008 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)
|
||||
|
||||
|
Reference in New Issue
Block a user