From 9dcc33ab1bb358cba06fc751dbf596913ef63c5c Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 26 Nov 2012 21:45:20 +0000 Subject: [PATCH 01/29] Removed missed usage of deprecated macros in Boost.Functional [SVN r81578] --- include/boost/functional/hash/extensions.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/functional/hash/extensions.hpp b/include/boost/functional/hash/extensions.hpp index 4358736..1ca7263 100644 --- a/include/boost/functional/hash/extensions.hpp +++ b/include/boost/functional/hash/extensions.hpp @@ -149,7 +149,7 @@ namespace boost } } -#if !defined(BOOST_NO_VARIADIC_TEMPLATES) +#if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) template inline std::size_t hash_value(std::tuple const& v) { From 03380087a9d65ecdc49eede1df773168aa9c47c7 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 2 Dec 2012 21:11:45 +0000 Subject: [PATCH 02/29] Hash: Don't use workarounds with recent compilers. #7221, #7470 [SVN r81677] --- doc/changes.qbk | 3 + .../hash/detail/float_functions.hpp | 90 +++++++++++++++++++ .../functional/hash/detail/hash_float.hpp | 9 +- 3 files changed, 101 insertions(+), 1 deletion(-) diff --git a/doc/changes.qbk b/doc/changes.qbk index c98bd86..b98e2ea 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -144,5 +144,8 @@ * Restore `enum` support, which was accidentally removed in the last version. * New floating point hasher - will hash the binary representation on more platforms, which should be faster. +* On platforms that are known to have standard floating point, don't use the + automatic detection of floating point functions - which can break if there + are ambiguous overloads. [endsect] diff --git a/include/boost/functional/hash/detail/float_functions.hpp b/include/boost/functional/hash/detail/float_functions.hpp index ae03ff0..4b8374d 100644 --- a/include/boost/functional/hash/detail/float_functions.hpp +++ b/include/boost/functional/hash/detail/float_functions.hpp @@ -13,6 +13,94 @@ # pragma once #endif +// Set BOOST_HASH_CONFORMANT_FLOATS to 1 for libraries known to have +// sufficiently good floating point support to not require any +// workarounds. +// +// When set to 0, the library tries to automatically +// use the best available implementation. This normally works well, but +// breaks when ambiguities are created by odd namespacing of the functions. +// +// Note that if this is set to 0, the library should still take full +// advantage of the platform's floating point support. + +#if defined(__SGI_STL_PORT) || defined(_STLPORT_VERSION) +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#elif defined(__LIBCOMO__) +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#elif defined(__STD_RWCOMPILER_H__) || defined(_RWSTD_VER) +// Rogue Wave library: +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#elif defined(_LIBCPP_VERSION) +// libc++ +# define BOOST_HASH_CONFORMANT_FLOATS 1 +#elif defined(__GLIBCPP__) || defined(__GLIBCXX__) +// GNU libstdc++ 3 +# if defined(__GNUC__) && __GNUC__ >= 4 +# define BOOST_HASH_CONFORMANT_FLOATS 1 +# else +# define BOOST_HASH_CONFORMANT_FLOATS 0 +# endif +#elif defined(__STL_CONFIG_H) +// generic SGI STL +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#elif defined(__MSL_CPP__) +// MSL standard lib: +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#elif defined(__IBMCPP__) +// VACPP std lib (probably conformant for much earlier version). +# if __IBMCPP__ >= 1210 +# define BOOST_HASH_CONFORMANT_FLOATS 1 +# else +# define BOOST_HASH_CONFORMANT_FLOATS 0 +# endif +#elif defined(MSIPL_COMPILE_H) +// Modena C++ standard library +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#elif (defined(_YVALS) && !defined(__IBMCPP__)) || defined(_CPPLIB_VER) +// Dinkumware Library (this has to appear after any possible replacement libraries): +# if _CPPLIB_VER >= 405 +# define BOOST_HASH_CONFORMANT_FLOATS 1 +# else +# define BOOST_HASH_CONFORMANT_FLOATS 0 +# endif +#else +# define BOOST_HASH_CONFORMANT_FLOATS 0 +#endif + +#if BOOST_HASH_CONFORMANT_FLOATS + +// The standard library is known to be compliant, so don't use the +// configuration mechanism. + +namespace boost { + namespace hash_detail { + template + struct call_ldexp { + typedef Float float_type; + inline Float operator()(Float x, int y) const { + return std::ldexp(x, y); + } + }; + + template + struct call_frexp { + typedef Float float_type; + inline Float operator()(Float x, int* y) const { + return std::frexp(x, y); + } + }; + + template + struct select_hash_type + { + typedef Float type; + }; + } +} + +#else // BOOST_HASH_CONFORMANT_FLOATS == 0 + // The C++ standard requires that the C float functions are overloarded // for float, double and long double in the std namespace, but some of the older // library implementations don't support this. On some that don't, the C99 @@ -243,4 +331,6 @@ namespace boost } } +#endif // BOOST_HASH_CONFORMANT_FLOATS + #endif diff --git a/include/boost/functional/hash/detail/hash_float.hpp b/include/boost/functional/hash/detail/hash_float.hpp index 3edc6ab..5e20b9c 100644 --- a/include/boost/functional/hash/detail/hash_float.hpp +++ b/include/boost/functional/hash/detail/hash_float.hpp @@ -210,8 +210,15 @@ namespace boost template inline std::size_t float_hash_value(T v) { +#if defined(fpclassify) + switch (fpclassify(v)) +#elif BOOST_HASH_CONFORMANT_FLOATS + switch (std::fpclassify(v)) +#else using namespace std; - switch (fpclassify(v)) { + switch (fpclassify(v)) +#endif + { case FP_ZERO: return 0; case FP_INFINITE: From 8afae2e7629f5e6a7ce04c0981ecbb4a5e683b08 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 2 Dec 2012 21:12:24 +0000 Subject: [PATCH 03/29] Hash: Remove container_fwd_0x.hpp [SVN r81678] --- .../hash/detail/container_fwd_0x.hpp | 29 ------------------- include/boost/functional/hash/extensions.hpp | 14 ++++++++- 2 files changed, 13 insertions(+), 30 deletions(-) delete mode 100644 include/boost/functional/hash/detail/container_fwd_0x.hpp diff --git a/include/boost/functional/hash/detail/container_fwd_0x.hpp b/include/boost/functional/hash/detail/container_fwd_0x.hpp deleted file mode 100644 index bed7730..0000000 --- a/include/boost/functional/hash/detail/container_fwd_0x.hpp +++ /dev/null @@ -1,29 +0,0 @@ - -// Copyright 2012 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) - -#if !defined(BOOST_DETAIL_CONTAINER_FWD_0X_HPP) -#define BOOST_DETAIL_CONTAINER_FWD_0X_HPP - -#include - -// std::array - -#if !defined(BOOST_NO_CXX11_HDR_ARRAY) -# include -#endif - -// std::tuple - -#if !defined(BOOST_NO_CXX11_HDR_TUPLE) -# include -#endif - -// std::shared_ptr/std::unique_ptr - -#if !defined(BOOST_NO_CXX11_HDR_MEMORY) -# include -#endif - -#endif diff --git a/include/boost/functional/hash/extensions.hpp b/include/boost/functional/hash/extensions.hpp index 1ca7263..998c08e 100644 --- a/include/boost/functional/hash/extensions.hpp +++ b/include/boost/functional/hash/extensions.hpp @@ -14,12 +14,24 @@ #define BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP #include -#include +#include #include #include #include #include +#if !defined(BOOST_NO_CXX11_HDR_ARRAY) +# include +#endif + +#if !defined(BOOST_NO_CXX11_HDR_TUPLE) +# include +#endif + +#if !defined(BOOST_NO_CXX11_HDR_MEMORY) +# include +#endif + #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif From 473b1da8deb2f365f36c63c1f106f135334c4aa4 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 2 Dec 2012 21:12:38 +0000 Subject: [PATCH 04/29] Hash: Avoid some intel warnings in tests. It doesn't have the GCC warning pragma, and doesn't like compiling the integer tests with floats (used to compile them, but never use them). [SVN r81679] --- test/hash_complex_test.cpp | 2 +- test/hash_float_test.hpp | 2 +- test/hash_number_test.cpp | 39 ++++++++++++++++++++++++++------------ 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/test/hash_complex_test.cpp b/test/hash_complex_test.cpp index bb1592c..36d2673 100644 --- a/test/hash_complex_test.cpp +++ b/test/hash_complex_test.cpp @@ -35,7 +35,7 @@ int main() {} #endif #endif -#if defined(__GNUC__) +#if defined(__GNUC__) && !defined(BOOST_INTEL_CXX_VERSION) #pragma GCC diagnostic ignored "-Wfloat-equal" #endif diff --git a/test/hash_float_test.hpp b/test/hash_float_test.hpp index c608915..a61d9de 100644 --- a/test/hash_float_test.hpp +++ b/test/hash_float_test.hpp @@ -30,7 +30,7 @@ #endif #endif -#if defined(__GNUC__) +#if defined(__GNUC__) && !defined(BOOST_INTEL_CXX_VERSION) #pragma GCC diagnostic ignored "-Wfloat-equal" #endif diff --git a/test/hash_number_test.cpp b/test/hash_number_test.cpp index 2645dfa..b7083c9 100644 --- a/test/hash_number_test.cpp +++ b/test/hash_number_test.cpp @@ -16,6 +16,7 @@ #include #include +#include #include "./compile_time.hpp" @@ -26,10 +27,34 @@ #pragma warning(disable:4310) // cast truncates constant value #endif -#if defined(__GNUC__) +#if defined(__GNUC__) && !defined(BOOST_INTEL_CXX_VERSION) #pragma GCC diagnostic ignored "-Wfloat-equal" #endif +template +void numeric_extra_tests(typename + boost::enable_if_c::is_integer, + void*>::type = 0) +{ + typedef boost::hash_detail::limits limits; + + if(limits::is_signed || + limits::digits <= boost::hash_detail::limits::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)); +} + +template +void numeric_extra_tests(typename + boost::disable_if_c::is_integer, + void*>::type = 0) +{ +} + template void numeric_test(T*) { @@ -55,17 +80,7 @@ void numeric_test(T*) BOOST_TEST(x1(T(10)) == HASH_NAMESPACE::hash_value(T(10))); BOOST_TEST(x1(T(25)) == HASH_NAMESPACE::hash_value(T(25))); - if (limits::is_integer) - { - if(limits::is_signed || - limits::digits <= boost::hash_detail::limits::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)); - } + numeric_extra_tests(); #endif } From be4292842d3c16e00200035ba9bdd106fd7ee9ff Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 4 Dec 2012 22:23:20 +0000 Subject: [PATCH 05/29] Hash: Stop using warnings as errors for Visual C++. I'd like to get full test results for Visual C++ with STLport. [SVN r81712] --- test/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 34b69e6..5325b19 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -12,7 +12,7 @@ project hash-tests intel:-strict-ansi gcc:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow" darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow" - msvc:on + #msvc:on #gcc:on #darwin:on ; From 67ad8c215103440770690c40288bd6d186ac0a48 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 8 Dec 2012 09:19:24 +0000 Subject: [PATCH 06/29] Hash: Detab. [SVN r81787] --- include/boost/functional/hash/hash.hpp | 6 +-- test/extra/check_float_funcs.cpp | 2 +- test/hash_enum_test.cpp | 68 +++++++++++++------------- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index 647fd68..1fc5566 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -94,7 +94,7 @@ namespace boost template typename boost::enable_if, std::size_t>::type - hash_value(T); + hash_value(T); #if !BOOST_WORKAROUND(__DMC__, <= 0x848) template std::size_t hash_value(T* const&); @@ -187,9 +187,9 @@ namespace boost template typename boost::enable_if, std::size_t>::type - hash_value(T v) + hash_value(T v) { - return static_cast(v); + return static_cast(v); } // Implementation by Alberto Barbati and Dave Harris. diff --git a/test/extra/check_float_funcs.cpp b/test/extra/check_float_funcs.cpp index a937082..01d5168 100644 --- a/test/extra/check_float_funcs.cpp +++ b/test/extra/check_float_funcs.cpp @@ -55,4 +55,4 @@ int main() { int (*fpc3)(long double) = std::fpclassify; #endif -} \ No newline at end of file +} diff --git a/test/hash_enum_test.cpp b/test/hash_enum_test.cpp index 30444e5..016ea69 100644 --- a/test/hash_enum_test.cpp +++ b/test/hash_enum_test.cpp @@ -15,49 +15,49 @@ #include "./compile_time.hpp" namespace test { - enum enum_override { enum_override1, enum_override2 }; - std::size_t hash_value(enum_override) { return 896532; } + enum enum_override { enum_override1, enum_override2 }; + std::size_t hash_value(enum_override) { return 896532; } - enum enum1 { enum1a }; - enum enum2 { enum2a, enum2b }; - enum enum3 { enum3a = 574, enum3b }; - enum enum4 { enum4a = -12574, enum4b }; + enum enum1 { enum1a }; + enum enum2 { enum2a, enum2b }; + enum enum3 { enum3a = 574, enum3b }; + enum enum4 { enum4a = -12574, enum4b }; } int main() { - compile_time_tests((test::enum1*) 0); - compile_time_tests((test::enum2*) 0); - compile_time_tests((test::enum3*) 0); - compile_time_tests((test::enum4*) 0); - compile_time_tests((test::enum_override*) 0); + compile_time_tests((test::enum1*) 0); + compile_time_tests((test::enum2*) 0); + compile_time_tests((test::enum3*) 0); + compile_time_tests((test::enum4*) 0); + compile_time_tests((test::enum_override*) 0); - HASH_NAMESPACE::hash hash1; - HASH_NAMESPACE::hash hash2; - HASH_NAMESPACE::hash hash3; - HASH_NAMESPACE::hash hash4; - - BOOST_TEST(hash1(test::enum1a) == hash1(test::enum1a)); + HASH_NAMESPACE::hash hash1; + HASH_NAMESPACE::hash hash2; + HASH_NAMESPACE::hash hash3; + HASH_NAMESPACE::hash hash4; - BOOST_TEST(hash2(test::enum2a) == hash2(test::enum2a)); - BOOST_TEST(hash2(test::enum2a) != hash2(test::enum2b)); - BOOST_TEST(hash2(test::enum2b) == hash2(test::enum2b)); + BOOST_TEST(hash1(test::enum1a) == hash1(test::enum1a)); - BOOST_TEST(hash3(test::enum3a) == hash3(test::enum3a)); - BOOST_TEST(hash3(test::enum3a) != hash3(test::enum3b)); - BOOST_TEST(hash3(test::enum3b) == hash3(test::enum3b)); + BOOST_TEST(hash2(test::enum2a) == hash2(test::enum2a)); + BOOST_TEST(hash2(test::enum2a) != hash2(test::enum2b)); + BOOST_TEST(hash2(test::enum2b) == hash2(test::enum2b)); - BOOST_TEST(hash4(test::enum4a) == hash4(test::enum4a)); - BOOST_TEST(hash4(test::enum4a) != hash4(test::enum4b)); - BOOST_TEST(hash4(test::enum4b) == hash4(test::enum4b)); + BOOST_TEST(hash3(test::enum3a) == hash3(test::enum3a)); + BOOST_TEST(hash3(test::enum3a) != hash3(test::enum3b)); + BOOST_TEST(hash3(test::enum3b) == hash3(test::enum3b)); - HASH_NAMESPACE::hash hash_override; + BOOST_TEST(hash4(test::enum4a) == hash4(test::enum4a)); + BOOST_TEST(hash4(test::enum4a) != hash4(test::enum4b)); + BOOST_TEST(hash4(test::enum4b) == hash4(test::enum4b)); - BOOST_TEST(hash_override(test::enum_override1) == - hash_override(test::enum_override1)); - BOOST_TEST(hash_override(test::enum_override1) == - hash_override(test::enum_override2)); - BOOST_TEST(hash_override(test::enum_override1) == - hash_override(test::enum_override1)); + HASH_NAMESPACE::hash hash_override; - return boost::report_errors(); + BOOST_TEST(hash_override(test::enum_override1) == + hash_override(test::enum_override1)); + BOOST_TEST(hash_override(test::enum_override1) == + hash_override(test::enum_override2)); + BOOST_TEST(hash_override(test::enum_override1) == + hash_override(test::enum_override1)); + + return boost::report_errors(); } From 0e0906b0a40e1f9a452affcf420e61fc94d7076e Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 10 Dec 2012 10:40:44 +0000 Subject: [PATCH 07/29] Hash: Support boost::int128_type. [SVN r81816] --- include/boost/functional/hash/hash.hpp | 20 ++++++++++++++++++-- test/hash_number_test.cpp | 5 +++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index 1fc5566..24318c8 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) @@ -40,8 +41,8 @@ namespace boost struct enable_hash_value { typedef std::size_t type; }; template struct basic_numbers {}; - template struct long_numbers {}; - template struct ulong_numbers {}; + template struct long_numbers; + template struct ulong_numbers; template struct float_numbers {}; template <> struct basic_numbers : @@ -70,6 +71,14 @@ namespace boost boost::hash_detail::enable_hash_value {}; #endif + // long_numbers is defined like this to allow for separate + // specialization for long_long and int128_type, in case + // they conflict. + template struct long_numbers2 {}; + template struct ulong_numbers2 {}; + template struct long_numbers : long_numbers2 {}; + template struct ulong_numbers : long_numbers2 {}; + #if !defined(BOOST_NO_LONG_LONG) template <> struct long_numbers : boost::hash_detail::enable_hash_value {}; @@ -77,6 +86,13 @@ namespace boost boost::hash_detail::enable_hash_value {}; #endif +#if defined(BOOST_HAS_INT128) + template <> struct long_numbers2 : + boost::hash_detail::enable_hash_value {}; + template <> struct ulong_numbers2 : + boost::hash_detail::enable_hash_value {}; +#endif + template <> struct float_numbers : boost::hash_detail::enable_hash_value {}; template <> struct float_numbers : diff --git a/test/hash_number_test.cpp b/test/hash_number_test.cpp index b7083c9..e4555e3 100644 --- a/test/hash_number_test.cpp +++ b/test/hash_number_test.cpp @@ -175,6 +175,11 @@ int main() NUMERIC_TEST_NO_LIMITS(boost::ulong_long_type, ulong_long) #endif +#if defined(BOOST_HAS_INT128) + NUMERIC_TEST_NO_LIMITS(boost::int128_type, int128) + NUMERIC_TEST_NO_LIMITS(boost::uint128_type, uint128) +#endif + NUMERIC_TEST(float, float) NUMERIC_TEST(double, double) From 13a86a7a261a7ce541333f57b8bd496c84de174d Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 11 Dec 2012 15:48:19 +0000 Subject: [PATCH 08/29] Hash: Fix int128 support. [SVN r81854] --- include/boost/functional/hash/hash.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index 24318c8..f94ffce 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -77,7 +77,7 @@ namespace boost template struct long_numbers2 {}; template struct ulong_numbers2 {}; template struct long_numbers : long_numbers2 {}; - template struct ulong_numbers : long_numbers2 {}; + template struct ulong_numbers : ulong_numbers2 {}; #if !defined(BOOST_NO_LONG_LONG) template <> struct long_numbers : From 8a8ab9ec706e6844d39925396abbf21debe64aee Mon Sep 17 00:00:00 2001 From: Daniel James Date: Wed, 12 Dec 2012 09:44:32 +0000 Subject: [PATCH 09/29] Hash: Fix int128 with BOOST_HASH_NO_EXTENSIONS. I don't think int128 should count as an extension. BOOST_HASH_NO_EXTENSIONS is actually a bit of a pain, and I don't think it's that useful. Maybe I should deprecate it. [SVN r81870] --- doc/changes.qbk | 3 +++ include/boost/functional/hash/hash.hpp | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/doc/changes.qbk b/doc/changes.qbk index b98e2ea..b20e58d 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -142,6 +142,9 @@ [h2 Boost 1.52.0] * Restore `enum` support, which was accidentally removed in the last version. +* Add support for `boost::int128_type` and `boost::uint128_type` where + available - currently only `__int128` and `unsigned __int128` on some + versions of gcc. * New floating point hasher - will hash the binary representation on more platforms, which should be faster. * On platforms that are known to have standard floating point, don't use the diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index f94ffce..aa4e49f 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -439,6 +439,11 @@ namespace boost BOOST_HASH_SPECIALIZE(boost::ulong_long_type) #endif +#if defined(BOOST_HAS_INT128) + BOOST_HASH_SPECIALIZE(boost::int128_type) + BOOST_HASH_SPECIALIZE(boost::uint128_type) +#endif + #if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) BOOST_HASH_SPECIALIZE(std::type_index) #endif From 9721f9c764e5ef353d87f9e06af4ebc942b9aa7e Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 17 Dec 2012 23:37:56 +0000 Subject: [PATCH 10/29] Hash: Safer macro names in tests. [SVN r82059] --- test/compile_time.hpp | 2 +- test/config.hpp | 10 +++--- test/hash_built_in_array_test.cpp | 30 ++++++++--------- test/hash_complex_test.cpp | 10 +++--- test/hash_custom_test.cpp | 28 ++++++++-------- test/hash_deque_test.cpp | 10 +++--- test/hash_enum_test.cpp | 12 +++---- test/hash_float_test.hpp | 48 +++++++++++++-------------- test/hash_friend_test.cpp | 28 ++++++++-------- test/hash_function_pointer_test.cpp | 12 +++---- test/hash_fwd_test.hpp | 22 ++++++------- test/hash_fwd_test_1.cpp | 36 ++++++++++----------- test/hash_fwd_test_2.cpp | 4 +-- test/hash_global_namespace_test.cpp | 28 ++++++++-------- test/hash_list_test.cpp | 10 +++--- test/hash_map_test.cpp | 10 +++--- test/hash_map_test.hpp | 6 ++-- test/hash_no_ext_fail_test.cpp | 4 +-- test/hash_no_ext_macro_1.cpp | 8 ++--- test/hash_no_ext_macro_2.cpp | 8 ++--- test/hash_number_test.cpp | 46 +++++++++++++------------- test/hash_pointer_test.cpp | 12 +++---- test/hash_range_test.cpp | 50 ++++++++++++++--------------- test/hash_sequence_test.hpp | 6 ++-- test/hash_set_test.cpp | 8 ++--- test/hash_set_test.hpp | 6 ++-- test/hash_std_array_test.cpp | 6 ++-- test/hash_std_smart_ptr_test.cpp | 22 ++++++------- test/hash_std_tuple_test.cpp | 6 ++-- test/hash_string_test.cpp | 38 +++++++++++----------- test/hash_type_index_test.cpp | 10 +++--- test/hash_value_array_test.cpp | 24 +++++++------- test/hash_vector_test.cpp | 10 +++--- test/link_ext_test.cpp | 12 +++---- test/link_no_ext_test.cpp | 4 +-- 35 files changed, 293 insertions(+), 293 deletions(-) diff --git a/test/compile_time.hpp b/test/compile_time.hpp index bd86038..40f39d8 100644 --- a/test/compile_time.hpp +++ b/test/compile_time.hpp @@ -11,6 +11,6 @@ template void compile_time_tests(T*) { BOOST_STATIC_ASSERT((boost::is_base_and_derived< - std::unary_function, HASH_NAMESPACE::hash >::value)); + std::unary_function, BOOST_HASH_TEST_NAMESPACE::hash >::value)); } diff --git a/test/config.hpp b/test/config.hpp index 216d9c4..53edf0a 100644 --- a/test/config.hpp +++ b/test/config.hpp @@ -3,13 +3,13 @@ // 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) -#if defined(TEST_STD) -# define TEST_STD_INCLUDES -# define HASH_NAMESPACE std +#if defined(BOOST_HASH_TEST_STD) +# define BOOST_HASH_TEST_STD_INCLUDES +# define BOOST_HASH_TEST_NAMESPACE std #else -# define HASH_NAMESPACE boost +# define BOOST_HASH_TEST_NAMESPACE boost # if !defined(BOOST_HASH_NO_EXTENSIONS) -# define TEST_EXTENSIONS +# define BOOST_HASH_TEST_EXTENSIONS # endif #endif diff --git a/test/hash_built_in_array_test.cpp b/test/hash_built_in_array_test.cpp index 9c91799..e2dfe99 100644 --- a/test/hash_built_in_array_test.cpp +++ b/test/hash_built_in_array_test.cpp @@ -5,8 +5,8 @@ #include "./config.hpp" -#ifdef TEST_EXTENSIONS -# ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_EXTENSIONS +# ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else # include @@ -15,7 +15,7 @@ #include -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS void array_int_test() { @@ -27,47 +27,47 @@ void array_int_test() 8, -12, 23, 65, 45, -1, 93, -54, 987, 3 }; - HASH_NAMESPACE::hash hasher1; + BOOST_HASH_TEST_NAMESPACE::hash hasher1; const int length2 = 1; int array2[1] = {3}; - HASH_NAMESPACE::hash hasher2; + BOOST_HASH_TEST_NAMESPACE::hash hasher2; const int length3 = 2; int array3[2] = {2, 3}; - HASH_NAMESPACE::hash hasher3; + BOOST_HASH_TEST_NAMESPACE::hash hasher3; BOOST_TEST(hasher1(array1) - == HASH_NAMESPACE::hash_range(array1, array1 + length1)); + == BOOST_HASH_TEST_NAMESPACE::hash_range(array1, array1 + length1)); BOOST_TEST(hasher2(array2) - == HASH_NAMESPACE::hash_range(array2, array2 + length2)); + == BOOST_HASH_TEST_NAMESPACE::hash_range(array2, array2 + length2)); BOOST_TEST(hasher3(array3) - == HASH_NAMESPACE::hash_range(array3, array3 + length3)); + == BOOST_HASH_TEST_NAMESPACE::hash_range(array3, array3 + length3)); } void two_dimensional_array_test() { int array[3][2] = {{-5, 6}, {7, -3}, {26, 1}}; - HASH_NAMESPACE::hash hasher; + BOOST_HASH_TEST_NAMESPACE::hash hasher; std::size_t seed1 = 0; for(int i = 0; i < 3; ++i) { std::size_t seed2 = 0; for(int j = 0; j < 2; ++j) - HASH_NAMESPACE::hash_combine(seed2, array[i][j]); - HASH_NAMESPACE::hash_combine(seed1, seed2); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, array[i][j]); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed1, seed2); } BOOST_TEST(hasher(array) == seed1); - BOOST_TEST(hasher(array) == HASH_NAMESPACE::hash_range(array, array + 3)); + BOOST_TEST(hasher(array) == BOOST_HASH_TEST_NAMESPACE::hash_range(array, array + 3)); } -#endif // TEST_EXTENSIONS +#endif // BOOST_HASH_TEST_EXTENSIONS int main() { -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS array_int_test(); two_dimensional_array_test(); #endif diff --git a/test/hash_complex_test.cpp b/test/hash_complex_test.cpp index 36d2673..617b51b 100644 --- a/test/hash_complex_test.cpp +++ b/test/hash_complex_test.cpp @@ -5,13 +5,13 @@ #include "./config.hpp" -#if !defined(TEST_EXTENSIONS) +#if !defined(BOOST_HASH_TEST_EXTENSIONS) int main() {} #else -#ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else # include @@ -46,11 +46,11 @@ int main() {} template void generic_complex_tests(std::complex v) { - HASH_NAMESPACE::hash > complex_hasher; + BOOST_HASH_TEST_NAMESPACE::hash > complex_hasher; BOOST_TEST(complex_hasher(v) == complex_hasher(v)); - HASH_NAMESPACE::hash real_hasher; + BOOST_HASH_TEST_NAMESPACE::hash real_hasher; T real = v.real(); T imag = v.imag(); @@ -107,4 +107,4 @@ int main() return boost::report_errors(); } -#endif // TEST_EXTENSIONS +#endif // BOOST_HASH_TEST_EXTENSIONS diff --git a/test/hash_custom_test.cpp b/test/hash_custom_test.cpp index 966df09..75f1c2b 100644 --- a/test/hash_custom_test.cpp +++ b/test/hash_custom_test.cpp @@ -41,8 +41,8 @@ namespace boost #include "./config.hpp" -#ifdef TEST_EXTENSIONS -# ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_EXTENSIONS +# ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else # include @@ -51,7 +51,7 @@ namespace boost #include -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS #include #include @@ -59,13 +59,13 @@ namespace boost void custom_tests() { - HASH_NAMESPACE::hash custom_hasher; + BOOST_HASH_TEST_NAMESPACE::hash custom_hasher; BOOST_TEST(custom_hasher(10) == 100u); test::custom x(55); BOOST_TEST(custom_hasher(x) == 550u); { - using namespace HASH_NAMESPACE; + using namespace BOOST_HASH_TEST_NAMESPACE; BOOST_TEST(custom_hasher(x) == hash_value(x)); } @@ -75,25 +75,25 @@ void custom_tests() custom_vector.push_back(35); std::size_t seed = 0; - HASH_NAMESPACE::hash_combine(seed, test::custom(5)); - HASH_NAMESPACE::hash_combine(seed, test::custom(25)); - HASH_NAMESPACE::hash_combine(seed, test::custom(35)); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, test::custom(5)); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, test::custom(25)); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, test::custom(35)); std::size_t seed2 = 0; - HASH_NAMESPACE::hash_combine(seed2, 50u); - HASH_NAMESPACE::hash_combine(seed2, 250u); - HASH_NAMESPACE::hash_combine(seed2, 350u); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 50u); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 250u); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 350u); - BOOST_TEST(seed == HASH_NAMESPACE::hash_range( + BOOST_TEST(seed == BOOST_HASH_TEST_NAMESPACE::hash_range( custom_vector.begin(), custom_vector.end())); BOOST_TEST(seed == seed2); } -#endif // TEST_EXTENSIONS +#endif // BOOST_HASH_TEST_EXTENSIONS int main() { -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS custom_tests(); #endif return boost::report_errors(); diff --git a/test/hash_deque_test.cpp b/test/hash_deque_test.cpp index bfb2691..4d7f447 100644 --- a/test/hash_deque_test.cpp +++ b/test/hash_deque_test.cpp @@ -5,8 +5,8 @@ #include "./config.hpp" -#ifdef TEST_EXTENSIONS -# ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_EXTENSIONS +# ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else # include @@ -15,7 +15,7 @@ #include -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS #include @@ -23,11 +23,11 @@ using std::deque; #define CONTAINER_TYPE deque #include "./hash_sequence_test.hpp" -#endif // TEST_EXTENSIONS +#endif // BOOST_HASH_TEST_EXTENSIONS int main() { -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS deque_tests::deque_hash_integer_tests(); #endif diff --git a/test/hash_enum_test.cpp b/test/hash_enum_test.cpp index 016ea69..2872b43 100644 --- a/test/hash_enum_test.cpp +++ b/test/hash_enum_test.cpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else # include @@ -31,10 +31,10 @@ int main() { compile_time_tests((test::enum4*) 0); compile_time_tests((test::enum_override*) 0); - HASH_NAMESPACE::hash hash1; - HASH_NAMESPACE::hash hash2; - HASH_NAMESPACE::hash hash3; - HASH_NAMESPACE::hash hash4; + BOOST_HASH_TEST_NAMESPACE::hash hash1; + BOOST_HASH_TEST_NAMESPACE::hash hash2; + BOOST_HASH_TEST_NAMESPACE::hash hash3; + BOOST_HASH_TEST_NAMESPACE::hash hash4; BOOST_TEST(hash1(test::enum1a) == hash1(test::enum1a)); @@ -50,7 +50,7 @@ int main() { BOOST_TEST(hash4(test::enum4a) != hash4(test::enum4b)); BOOST_TEST(hash4(test::enum4b) == hash4(test::enum4b)); - HASH_NAMESPACE::hash hash_override; + BOOST_HASH_TEST_NAMESPACE::hash hash_override; BOOST_TEST(hash_override(test::enum_override1) == hash_override(test::enum_override1)); diff --git a/test/hash_float_test.hpp b/test/hash_float_test.hpp index a61d9de..8c2a43a 100644 --- a/test/hash_float_test.hpp +++ b/test/hash_float_test.hpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else # include @@ -43,7 +43,7 @@ void float_tests(char const* name, T* = 0) { std::cerr << "\n" - << "Testing " BOOST_STRINGIZE(HASH_NAMESPACE) "::hash<" + << "Testing " BOOST_STRINGIZE(BOOST_HASH_TEST_NAMESPACE) "::hash<" << name << ">\n" << "\n" @@ -70,7 +70,7 @@ void float_tests(char const* name, T* = 0) << "\n" ; - HASH_NAMESPACE::hash x1; + BOOST_HASH_TEST_NAMESPACE::hash x1; T zero = 0; T minus_zero = (T) -1 * zero; @@ -78,9 +78,9 @@ void float_tests(char const* name, T* = 0) BOOST_TEST(zero == minus_zero); BOOST_TEST(x1(zero) == x1(minus_zero)); -#if defined(TEST_EXTENSIONS) - BOOST_TEST(x1(zero) == HASH_NAMESPACE::hash_value(zero)); - BOOST_TEST(x1(minus_zero) == HASH_NAMESPACE::hash_value(minus_zero)); +#if defined(BOOST_HASH_TEST_EXTENSIONS) + BOOST_TEST(x1(zero) == BOOST_HASH_TEST_NAMESPACE::hash_value(zero)); + BOOST_TEST(x1(minus_zero) == BOOST_HASH_TEST_NAMESPACE::hash_value(minus_zero)); #endif BOOST_TEST(x1(zero) != x1(0.5)); @@ -106,10 +106,10 @@ void float_tests(char const* name, T* = 0) T minus_infinity2 = (T) -1. / zero; T minus_infinity3 = (T) 1. / minus_zero; -#if defined(TEST_EXTENSIONS) - BOOST_TEST(x1(infinity) == HASH_NAMESPACE::hash_value(infinity)); +#if defined(BOOST_HASH_TEST_EXTENSIONS) + BOOST_TEST(x1(infinity) == BOOST_HASH_TEST_NAMESPACE::hash_value(infinity)); BOOST_TEST(x1(minus_infinity) - == HASH_NAMESPACE::hash_value(minus_infinity)); + == BOOST_HASH_TEST_NAMESPACE::hash_value(minus_infinity)); #endif if(infinity == infinity2) @@ -191,12 +191,12 @@ void float_tests(char const* name, T* = 0) BOOST_TEST(three_quarter_max != -three_quarter_max); -#if defined(TEST_EXTENSIONS) - 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)); +#if defined(BOOST_HASH_TEST_EXTENSIONS) + BOOST_TEST(x1(max) == BOOST_HASH_TEST_NAMESPACE::hash_value(max)); + BOOST_TEST(x1(half_max) == BOOST_HASH_TEST_NAMESPACE::hash_value(half_max)); + BOOST_TEST(x1(quarter_max) == BOOST_HASH_TEST_NAMESPACE::hash_value(quarter_max)); BOOST_TEST(x1(three_quarter_max) == - HASH_NAMESPACE::hash_value(three_quarter_max)); + BOOST_HASH_TEST_NAMESPACE::hash_value(three_quarter_max)); #endif // The '!=' tests could legitimately fail, but with my hash it indicates a @@ -227,16 +227,16 @@ void float_tests(char const* name, T* = 0) if(v1 == v2) BOOST_TEST(x1(v1) == x1(v2)); -#if defined(TEST_EXTENSIONS) - BOOST_TEST(x1(v1) == HASH_NAMESPACE::hash_value(v1)); - BOOST_TEST(x1(v2) == HASH_NAMESPACE::hash_value(v2)); +#if defined(BOOST_HASH_TEST_EXTENSIONS) + BOOST_TEST(x1(v1) == BOOST_HASH_TEST_NAMESPACE::hash_value(v1)); + BOOST_TEST(x1(v2) == BOOST_HASH_TEST_NAMESPACE::hash_value(v2)); #endif #endif -#if defined(TEST_EXTENSIONS) +#if defined(BOOST_HASH_TEST_EXTENSIONS) BOOST_TEST(x1(boost::hash_detail::limits::epsilon()) == - HASH_NAMESPACE::hash_value( + BOOST_HASH_TEST_NAMESPACE::hash_value( boost::hash_detail::limits::epsilon())); #endif @@ -269,12 +269,12 @@ void float_tests(char const* name, T* = 0) if(x1(boost::hash_detail::limits::denorm_min()) == x1(zero)) { std::cerr<<"x1(denorm_min) == x1(zero) == "<::denorm_min()) != - HASH_NAMESPACE::hash_value( + BOOST_HASH_TEST_NAMESPACE::hash_value( boost::hash_detail::limits::denorm_min())) { std::cerr @@ -282,7 +282,7 @@ void float_tests(char const* name, T* = 0) << x1(boost::hash_detail::limits::denorm_min()) << "\nhash_value(boost::hash_detail::limits::denorm_min())" " = " - << HASH_NAMESPACE::hash_value( + << BOOST_HASH_TEST_NAMESPACE::hash_value( boost::hash_detail::limits::denorm_min()) << "\nx1(0) = " << x1(0) @@ -292,13 +292,13 @@ void float_tests(char const* name, T* = 0) } // NaN also causes borland to crash. -#if !defined(__BORLANDC__) && defined(TEST_EXTENSIONS) +#if !defined(__BORLANDC__) && defined(BOOST_HASH_TEST_EXTENSIONS) if(boost::hash_detail::limits::has_quiet_NaN) { if(x1(boost::hash_detail::limits::quiet_NaN()) == x1(1.0)) { std::cerr<<"x1(quiet_NaN) == x1(1.0) == "<::quiet_NaN()) == - HASH_NAMESPACE::hash_value( + BOOST_HASH_TEST_NAMESPACE::hash_value( boost::hash_detail::limits::quiet_NaN())); } #endif diff --git a/test/hash_friend_test.cpp b/test/hash_friend_test.cpp index 9d84570..03755a8 100644 --- a/test/hash_friend_test.cpp +++ b/test/hash_friend_test.cpp @@ -44,8 +44,8 @@ namespace boost #include "./config.hpp" -#ifdef TEST_EXTENSIONS -# ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_EXTENSIONS +# ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else # include @@ -54,7 +54,7 @@ namespace boost #include -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS #include #include @@ -62,13 +62,13 @@ namespace boost void custom_tests() { - HASH_NAMESPACE::hash > custom_hasher; + BOOST_HASH_TEST_NAMESPACE::hash > custom_hasher; BOOST_TEST(custom_hasher(10) == 100u); test::custom x(55); BOOST_TEST(custom_hasher(x) == 550u); { - using namespace HASH_NAMESPACE; + using namespace BOOST_HASH_TEST_NAMESPACE; BOOST_TEST(custom_hasher(x) == hash_value(x)); } @@ -78,25 +78,25 @@ void custom_tests() custom_vector.push_back(35); std::size_t seed = 0; - HASH_NAMESPACE::hash_combine(seed, test::custom(5)); - HASH_NAMESPACE::hash_combine(seed, test::custom(25)); - HASH_NAMESPACE::hash_combine(seed, test::custom(35)); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, test::custom(5)); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, test::custom(25)); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, test::custom(35)); std::size_t seed2 = 0; - HASH_NAMESPACE::hash_combine(seed2, 50u); - HASH_NAMESPACE::hash_combine(seed2, 250u); - HASH_NAMESPACE::hash_combine(seed2, 350u); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 50u); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 250u); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 350u); - BOOST_TEST(seed == HASH_NAMESPACE::hash_range( + BOOST_TEST(seed == BOOST_HASH_TEST_NAMESPACE::hash_range( custom_vector.begin(), custom_vector.end())); BOOST_TEST(seed == seed2); } -#endif // TEST_EXTENSIONS +#endif // BOOST_HASH_TEST_EXTENSIONS int main() { -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS custom_tests(); #endif return boost::report_errors(); diff --git a/test/hash_function_pointer_test.cpp b/test/hash_function_pointer_test.cpp index a73b718..50fedf7 100644 --- a/test/hash_function_pointer_test.cpp +++ b/test/hash_function_pointer_test.cpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else # include @@ -24,8 +24,8 @@ void function_pointer_tests() compile_time_tests((void(**)()) 0); compile_time_tests((int(**)(int)) 0); - HASH_NAMESPACE::hash hasher_void; - HASH_NAMESPACE::hash hasher_int; + BOOST_HASH_TEST_NAMESPACE::hash hasher_void; + BOOST_HASH_TEST_NAMESPACE::hash hasher_int; BOOST_TEST(&void_func1 != &void_func2); BOOST_TEST(&int_func1 != &int_func2); @@ -38,11 +38,11 @@ void function_pointer_tests() 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)); -#if defined(TEST_EXTENSIONS) +#if defined(BOOST_HASH_TEST_EXTENSIONS) BOOST_TEST(hasher_void(&void_func1) - == HASH_NAMESPACE::hash_value(&void_func1)); + == BOOST_HASH_TEST_NAMESPACE::hash_value(&void_func1)); BOOST_TEST(hasher_int(&int_func1) - == HASH_NAMESPACE::hash_value(&int_func1)); + == BOOST_HASH_TEST_NAMESPACE::hash_value(&int_func1)); // This isn't specified in Peter's proposal: BOOST_TEST(hasher_void(0) == 0); diff --git a/test/hash_fwd_test.hpp b/test/hash_fwd_test.hpp index 09ef3b3..d3c8186 100644 --- a/test/hash_fwd_test.hpp +++ b/test/hash_fwd_test.hpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#if defined(TEST_EXTENSIONS) && !defined(TEST_STD_INCLUDES) +#if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_HASH_TEST_STD_INCLUDES) #include #include @@ -25,7 +25,7 @@ namespace test { template std::size_t hash_value(test_type1 const& x) { - HASH_NAMESPACE::hash hasher; + BOOST_HASH_TEST_NAMESPACE::hash hasher; return hasher(x.value); } #endif @@ -42,8 +42,8 @@ namespace test { std::size_t hash_value(test_type2 const& x) { std::size_t seed = 0; - HASH_NAMESPACE::hash_combine(seed, x.value1); - HASH_NAMESPACE::hash_combine(seed, x.value2); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, x.value1); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, x.value2); return seed; } #endif @@ -61,8 +61,8 @@ namespace test { std::size_t hash_value(test_type3 const& x) { std::size_t seed = - HASH_NAMESPACE::hash_range(x.values.begin(), x.values.end()); - HASH_NAMESPACE::hash_range(seed, x.values.begin(), x.values.end()); + BOOST_HASH_TEST_NAMESPACE::hash_range(x.values.begin(), x.values.end()); + BOOST_HASH_TEST_NAMESPACE::hash_range(seed, x.values.begin(), x.values.end()); return seed; } #endif @@ -76,7 +76,7 @@ namespace boost template std::size_t hash_value(test::test_type1 const& x) { - HASH_NAMESPACE::hash hasher; + BOOST_HASH_TEST_NAMESPACE::hash hasher; return hasher(x.value); } @@ -84,8 +84,8 @@ namespace boost std::size_t hash_value(test::test_type2 const& x) { std::size_t seed = 0; - HASH_NAMESPACE::hash_combine(seed, x.value1); - HASH_NAMESPACE::hash_combine(seed, x.value2); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, x.value1); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, x.value2); return seed; } @@ -93,8 +93,8 @@ namespace boost std::size_t hash_value(test::test_type3 const& x) { std::size_t seed = - HASH_NAMESPACE::hash_range(x.values.begin(), x.values.end()); - HASH_NAMESPACE::hash_range(seed, x.values.begin(), x.values.end()); + BOOST_HASH_TEST_NAMESPACE::hash_range(x.values.begin(), x.values.end()); + BOOST_HASH_TEST_NAMESPACE::hash_range(seed, x.values.begin(), x.values.end()); return seed; } } diff --git a/test/hash_fwd_test_1.cpp b/test/hash_fwd_test_1.cpp index 1f27f65..68fdde2 100644 --- a/test/hash_fwd_test_1.cpp +++ b/test/hash_fwd_test_1.cpp @@ -11,7 +11,7 @@ #include -#if defined(TEST_EXTENSIONS) && !defined(TEST_STD_INCLUDES) +#if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_HASH_TEST_STD_INCLUDES) #include #include @@ -21,10 +21,10 @@ void fwd_test1() test::test_type1 x(5); test::test_type1 y("Test"); - HASH_NAMESPACE::hash hasher_int; - HASH_NAMESPACE::hash hasher_string; - HASH_NAMESPACE::hash > hasher_test_int; - HASH_NAMESPACE::hash > hasher_test_string; + BOOST_HASH_TEST_NAMESPACE::hash hasher_int; + BOOST_HASH_TEST_NAMESPACE::hash hasher_string; + BOOST_HASH_TEST_NAMESPACE::hash > hasher_test_int; + BOOST_HASH_TEST_NAMESPACE::hash > hasher_test_string; BOOST_TEST(hasher_int(5) == hasher_test_int(x)); BOOST_TEST(hasher_string("Test") == hasher_test_string(y)); @@ -36,15 +36,15 @@ void fwd_test2() test::test_type2 y("Test1", "Test2"); std::size_t seed1 = 0; - HASH_NAMESPACE::hash_combine(seed1, 5); - HASH_NAMESPACE::hash_combine(seed1, 10); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed1, 5); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed1, 10); std::size_t seed2 = 0; - HASH_NAMESPACE::hash_combine(seed2, std::string("Test1")); - HASH_NAMESPACE::hash_combine(seed2, std::string("Test2")); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, std::string("Test1")); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, std::string("Test2")); - HASH_NAMESPACE::hash > hasher_test_int; - HASH_NAMESPACE::hash > hasher_test_string; + BOOST_HASH_TEST_NAMESPACE::hash > hasher_test_int; + BOOST_HASH_TEST_NAMESPACE::hash > hasher_test_string; BOOST_TEST(seed1 == hasher_test_int(x)); BOOST_TEST(seed2 == hasher_test_string(y)); @@ -69,15 +69,15 @@ void fwd_test3() test::test_type3 y(values2.begin(), values2.end()); std::size_t seed1 = - HASH_NAMESPACE::hash_range(values1.begin(), values1.end()); - HASH_NAMESPACE::hash_range(seed1, values1.begin(), values1.end()); + BOOST_HASH_TEST_NAMESPACE::hash_range(values1.begin(), values1.end()); + BOOST_HASH_TEST_NAMESPACE::hash_range(seed1, values1.begin(), values1.end()); std::size_t seed2 = - HASH_NAMESPACE::hash_range(values2.begin(), values2.end()); - HASH_NAMESPACE::hash_range(seed2, values2.begin(), values2.end()); + BOOST_HASH_TEST_NAMESPACE::hash_range(values2.begin(), values2.end()); + BOOST_HASH_TEST_NAMESPACE::hash_range(seed2, values2.begin(), values2.end()); - HASH_NAMESPACE::hash > hasher_test_int; - HASH_NAMESPACE::hash > hasher_test_string; + BOOST_HASH_TEST_NAMESPACE::hash > hasher_test_int; + BOOST_HASH_TEST_NAMESPACE::hash > hasher_test_string; BOOST_TEST(seed1 == hasher_test_int(x)); BOOST_TEST(seed2 == hasher_test_string(y)); @@ -87,7 +87,7 @@ void fwd_test3() int main() { -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS fwd_test1(); fwd_test2(); fwd_test3(); diff --git a/test/hash_fwd_test_2.cpp b/test/hash_fwd_test_2.cpp index 869f67b..d4c1a32 100644 --- a/test/hash_fwd_test_2.cpp +++ b/test/hash_fwd_test_2.cpp @@ -8,7 +8,7 @@ #include "./config.hpp" -#if !defined(TEST_EXTENSIONS) || defined(TEST_STD_INCLUDES) +#if !defined(BOOST_HASH_TEST_EXTENSIONS) || defined(BOOST_HASH_TEST_STD_INCLUDES) int main() {} @@ -44,4 +44,4 @@ int main() return boost::report_errors(); } -#endif // defined(TEST_EXTENSIONS) && !defined(TEST_STD_INCLUDES) +#endif // defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_HASH_TEST_STD_INCLUDES) diff --git a/test/hash_global_namespace_test.cpp b/test/hash_global_namespace_test.cpp index d1d504d..877ff00 100644 --- a/test/hash_global_namespace_test.cpp +++ b/test/hash_global_namespace_test.cpp @@ -42,8 +42,8 @@ namespace boost #include "./config.hpp" -#ifdef TEST_EXTENSIONS -# ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_EXTENSIONS +# ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else # include @@ -52,7 +52,7 @@ namespace boost #include -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS #include #include @@ -60,13 +60,13 @@ namespace boost void custom_tests() { - HASH_NAMESPACE::hash custom_hasher; + BOOST_HASH_TEST_NAMESPACE::hash custom_hasher; BOOST_TEST(custom_hasher(10) == 100u); custom x(55); BOOST_TEST(custom_hasher(x) == 550u); { - using namespace HASH_NAMESPACE; + using namespace BOOST_HASH_TEST_NAMESPACE; BOOST_TEST(custom_hasher(x) == hash_value(x)); } @@ -76,26 +76,26 @@ void custom_tests() custom_vector.push_back(35); std::size_t seed = 0; - HASH_NAMESPACE::hash_combine(seed, custom(5)); - HASH_NAMESPACE::hash_combine(seed, custom(25)); - HASH_NAMESPACE::hash_combine(seed, custom(35)); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, custom(5)); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, custom(25)); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed, custom(35)); std::size_t seed2 = 0; - HASH_NAMESPACE::hash_combine(seed2, 50u); - HASH_NAMESPACE::hash_combine(seed2, 250u); - HASH_NAMESPACE::hash_combine(seed2, 350u); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 50u); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 250u); + BOOST_HASH_TEST_NAMESPACE::hash_combine(seed2, 350u); - BOOST_TEST(seed == HASH_NAMESPACE::hash_range( + BOOST_TEST(seed == BOOST_HASH_TEST_NAMESPACE::hash_range( custom_vector.begin(), custom_vector.end())); BOOST_TEST(seed == seed2); } -#endif // TEST_EXTENSIONS +#endif // BOOST_HASH_TEST_EXTENSIONS int main() { -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS custom_tests(); #endif return boost::report_errors(); diff --git a/test/hash_list_test.cpp b/test/hash_list_test.cpp index 30560d3..a0f9716 100644 --- a/test/hash_list_test.cpp +++ b/test/hash_list_test.cpp @@ -5,8 +5,8 @@ #include "./config.hpp" -#ifdef TEST_EXTENSIONS -# ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_EXTENSIONS +# ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else # include @@ -15,7 +15,7 @@ #include -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS #include @@ -23,11 +23,11 @@ using std::list; #define CONTAINER_TYPE list #include "./hash_sequence_test.hpp" -#endif // TEST_EXTENSIONS +#endif // BOOST_HASH_TEST_EXTENSIONS int main() { -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS list_tests::list_hash_integer_tests(); #endif diff --git a/test/hash_map_test.cpp b/test/hash_map_test.cpp index 7e117c7..01a7854 100644 --- a/test/hash_map_test.cpp +++ b/test/hash_map_test.cpp @@ -5,8 +5,8 @@ #include "./config.hpp" -#ifdef TEST_EXTENSIONS -# ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_EXTENSIONS +# ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else # include @@ -17,7 +17,7 @@ #include -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS using std::map; #define CONTAINER_TYPE map @@ -27,11 +27,11 @@ using std::multimap; #define CONTAINER_TYPE multimap #include "./hash_map_test.hpp" -#endif // TEST_EXTENSIONS +#endif // BOOST_HASH_TEST_EXTENSIONS int main() { -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS map_tests::map_hash_integer_tests(); multimap_tests::multimap_hash_integer_tests(); #endif diff --git a/test/hash_map_test.hpp b/test/hash_map_test.hpp index bd0255f..41bb2fa 100644 --- a/test/hash_map_test.hpp +++ b/test/hash_map_test.hpp @@ -38,16 +38,16 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) containers[9].insert(pair(key(-1),value(3))); containers[9].insert(pair(key(-1),value(3))); - HASH_NAMESPACE::hash hasher; + BOOST_HASH_TEST_NAMESPACE::hash hasher; for(int i2 = 0; i2 < number_of_containers; ++i2) { BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2])); BOOST_TEST(hasher(containers[i2]) == - HASH_NAMESPACE::hash_value(containers[i2])); + BOOST_HASH_TEST_NAMESPACE::hash_value(containers[i2])); BOOST_TEST(hasher(containers[i2]) - == HASH_NAMESPACE::hash_range( + == BOOST_HASH_TEST_NAMESPACE::hash_range( containers[i2].begin(), containers[i2].end())); for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) { diff --git a/test/hash_no_ext_fail_test.cpp b/test/hash_no_ext_fail_test.cpp index 22f6f5a..6d1636e 100644 --- a/test/hash_no_ext_fail_test.cpp +++ b/test/hash_no_ext_fail_test.cpp @@ -11,7 +11,7 @@ # define BOOST_HASH_NO_EXTENSIONS #endif -#ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else # include @@ -21,7 +21,7 @@ template void ignore(T const&) {} int main() { - HASH_NAMESPACE::hash< int[10] > hasher; + BOOST_HASH_TEST_NAMESPACE::hash< int[10] > hasher; ignore(hasher); return 0; diff --git a/test/hash_no_ext_macro_1.cpp b/test/hash_no_ext_macro_1.cpp index ea727bb..d69e5b5 100644 --- a/test/hash_no_ext_macro_1.cpp +++ b/test/hash_no_ext_macro_1.cpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#if defined(TEST_EXTENSIONS) +#if defined(BOOST_HASH_TEST_EXTENSIONS) // Include header without BOOST_HASH_NO_EXTENSIONS defined # if defined(BOOST_HASH_NO_EXTENSIONS) @@ -23,14 +23,14 @@ int main() { -#if defined(TEST_EXTENSIONS) +#if defined(BOOST_HASH_TEST_EXTENSIONS) std::deque x; x.push_back(1); x.push_back(2); - HASH_NAMESPACE::hash > hasher; - BOOST_TEST(hasher(x) == HASH_NAMESPACE::hash_value(x)); + BOOST_HASH_TEST_NAMESPACE::hash > hasher; + BOOST_TEST(hasher(x) == BOOST_HASH_TEST_NAMESPACE::hash_value(x)); #endif return boost::report_errors(); diff --git a/test/hash_no_ext_macro_2.cpp b/test/hash_no_ext_macro_2.cpp index a8d8c65..fe548ee 100644 --- a/test/hash_no_ext_macro_2.cpp +++ b/test/hash_no_ext_macro_2.cpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#if defined(TEST_EXTENSIONS) +#if defined(BOOST_HASH_TEST_EXTENSIONS) // Include header with BOOST_HASH_NO_EXTENSIONS defined # if !defined(BOOST_HASH_NO_EXTENSIONS) @@ -23,14 +23,14 @@ int main() { -#if defined(TEST_EXTENSIONS) +#if defined(BOOST_HASH_TEST_EXTENSIONS) std::map x; x.insert(std::map::value_type(53, -42)); x.insert(std::map::value_type(14, -75)); - HASH_NAMESPACE::hash > hasher; - BOOST_TEST(hasher(x) == HASH_NAMESPACE::hash_value(x)); + BOOST_HASH_TEST_NAMESPACE::hash > hasher; + BOOST_TEST(hasher(x) == BOOST_HASH_TEST_NAMESPACE::hash_value(x)); #endif return boost::report_errors(); diff --git a/test/hash_number_test.cpp b/test/hash_number_test.cpp index e4555e3..242c731 100644 --- a/test/hash_number_test.cpp +++ b/test/hash_number_test.cpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else # include @@ -41,11 +41,11 @@ void numeric_extra_tests(typename if(limits::is_signed || limits::digits <= boost::hash_detail::limits::digits) { - BOOST_TEST(HASH_NAMESPACE::hash_value(T(-5)) == (std::size_t)T(-5)); + BOOST_TEST(BOOST_HASH_TEST_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)); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(T(0)) == (std::size_t)T(0u)); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(T(10)) == (std::size_t)T(10u)); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(T(25)) == (std::size_t)T(25u)); } template @@ -62,8 +62,8 @@ void numeric_test(T*) compile_time_tests((T*) 0); - HASH_NAMESPACE::hash x1; - HASH_NAMESPACE::hash x2; + BOOST_HASH_TEST_NAMESPACE::hash x1; + BOOST_HASH_TEST_NAMESPACE::hash x2; T v1 = (T) -5; BOOST_TEST(x1(v1) == x2(v1)); @@ -74,11 +74,11 @@ void numeric_test(T*) BOOST_TEST(x1(T(5) - T(5)) == x2(T(0))); BOOST_TEST(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))); +#if defined(BOOST_HASH_TEST_EXTENSIONS) + BOOST_TEST(x1(T(-5)) == BOOST_HASH_TEST_NAMESPACE::hash_value(T(-5))); + BOOST_TEST(x1(T(0)) == BOOST_HASH_TEST_NAMESPACE::hash_value(T(0))); + BOOST_TEST(x1(T(10)) == BOOST_HASH_TEST_NAMESPACE::hash_value(T(10))); + BOOST_TEST(x1(T(25)) == BOOST_HASH_TEST_NAMESPACE::hash_value(T(25))); numeric_extra_tests(); #endif @@ -91,8 +91,8 @@ void limits_test(T*) if(limits::is_specialized) { - HASH_NAMESPACE::hash x1; - HASH_NAMESPACE::hash x2; + BOOST_HASH_TEST_NAMESPACE::hash x1; + BOOST_HASH_TEST_NAMESPACE::hash x2; T min_value = (limits::min)(); T max_value = (limits::max)(); @@ -100,15 +100,15 @@ void limits_test(T*) BOOST_TEST(x1(min_value) == x2((limits::min)())); BOOST_TEST(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)); +#if defined(BOOST_HASH_TEST_EXTENSIONS) + BOOST_TEST(x1(min_value) == BOOST_HASH_TEST_NAMESPACE::hash_value(min_value)); + BOOST_TEST(x1(max_value) == BOOST_HASH_TEST_NAMESPACE::hash_value(max_value)); if (limits::is_integer) { - BOOST_TEST(HASH_NAMESPACE::hash_value(min_value) + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(min_value) == std::size_t(min_value)); - BOOST_TEST(HASH_NAMESPACE::hash_value(max_value) + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(max_value) == std::size_t(max_value)); } #endif @@ -120,8 +120,8 @@ void poor_quality_tests(T*) { typedef boost::hash_detail::limits limits; - HASH_NAMESPACE::hash x1; - HASH_NAMESPACE::hash x2; + BOOST_HASH_TEST_NAMESPACE::hash x1; + BOOST_HASH_TEST_NAMESPACE::hash x2; // A hash function can legally fail these tests, but it'll not be a good // sign. @@ -136,8 +136,8 @@ void poor_quality_tests(T*) void bool_test() { - HASH_NAMESPACE::hash x1; - HASH_NAMESPACE::hash x2; + BOOST_HASH_TEST_NAMESPACE::hash x1; + BOOST_HASH_TEST_NAMESPACE::hash x2; BOOST_TEST(x1(true) == x2(true)); BOOST_TEST(x1(false) == x2(false)); diff --git a/test/hash_pointer_test.cpp b/test/hash_pointer_test.cpp index b255a28..7cacaa8 100644 --- a/test/hash_pointer_test.cpp +++ b/test/hash_pointer_test.cpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else # include @@ -20,8 +20,8 @@ void pointer_tests() compile_time_tests((int**) 0); compile_time_tests((void**) 0); - HASH_NAMESPACE::hash x1; - HASH_NAMESPACE::hash x2; + BOOST_HASH_TEST_NAMESPACE::hash x1; + BOOST_HASH_TEST_NAMESPACE::hash x2; int int1; int int2; @@ -29,9 +29,9 @@ void pointer_tests() BOOST_TEST(x1(0) == x2(0)); BOOST_TEST(x1(&int1) == x2(&int1)); BOOST_TEST(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)); +#if defined(BOOST_HASH_TEST_EXTENSIONS) + BOOST_TEST(x1(&int1) == BOOST_HASH_TEST_NAMESPACE::hash_value(&int1)); + BOOST_TEST(x1(&int2) == BOOST_HASH_TEST_NAMESPACE::hash_value(&int2)); // This isn't specified in Peter's proposal: BOOST_TEST(x1(0) == 0); diff --git a/test/hash_range_test.cpp b/test/hash_range_test.cpp index f5fdb2a..a5bdbb6 100644 --- a/test/hash_range_test.cpp +++ b/test/hash_range_test.cpp @@ -5,13 +5,13 @@ #include "./config.hpp" -#if !defined(TEST_EXTENSIONS) +#if !defined(BOOST_HASH_TEST_EXTENSIONS) int main() {} #else -#ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else # include @@ -40,39 +40,39 @@ void hash_range_tests() std::vector x; std::size_t x_seed = 0; - BOOST_TEST(x_seed == HASH_NAMESPACE::hash_range(x.begin(), x.end())); + BOOST_TEST(x_seed == BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(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()) - != HASH_NAMESPACE::hash_range(values1.begin(), values1.end())); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(empty.begin(), empty.end()) + == BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(empty.begin(), empty.end()) + != BOOST_HASH_TEST_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_HASH_TEST_NAMESPACE::hash_combine(x_seed, 10); + BOOST_TEST(x_seed == BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(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()) - == HASH_NAMESPACE::hash_range(x.begin(), x.end())); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(empty.begin(), empty.end()) + != BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(values2.begin(), values2.end()) + == BOOST_HASH_TEST_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_HASH_TEST_NAMESPACE::hash_combine(x_seed, 20); + BOOST_TEST(x_seed == BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(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()) - != HASH_NAMESPACE::hash_range(x.begin(), x.end())); - BOOST_TEST(HASH_NAMESPACE::hash_range(values3.begin(), values3.end()) - == HASH_NAMESPACE::hash_range(x.begin(), x.end())); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(empty.begin(), empty.end()) + != BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(values2.begin(), values2.end()) + != BOOST_HASH_TEST_NAMESPACE::hash_range(x.begin(), x.end())); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_range(values3.begin(), values3.end()) + == BOOST_HASH_TEST_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_HASH_TEST_NAMESPACE::hash_range(values3.begin(), values3.end()); + BOOST_HASH_TEST_NAMESPACE::hash_range(seed, values4.begin(), values4.end()); + BOOST_HASH_TEST_NAMESPACE::hash_range(seed, x.begin(), x.end()); BOOST_TEST(seed == - HASH_NAMESPACE::hash_range(values5.begin(), values5.end())); + BOOST_HASH_TEST_NAMESPACE::hash_range(values5.begin(), values5.end())); } int main() diff --git a/test/hash_sequence_test.hpp b/test/hash_sequence_test.hpp index 4093bc4..e0846b0 100644 --- a/test/hash_sequence_test.hpp +++ b/test/hash_sequence_test.hpp @@ -38,16 +38,16 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) containers[10].push_back(-1); containers[10].push_back(1); - HASH_NAMESPACE::hash hasher; + BOOST_HASH_TEST_NAMESPACE::hash hasher; for(int i2 = 0; i2 < number_of_containers; ++i2) { BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2])); BOOST_TEST(hasher(containers[i2]) == - HASH_NAMESPACE::hash_value(containers[i2])); + BOOST_HASH_TEST_NAMESPACE::hash_value(containers[i2])); BOOST_TEST(hasher(containers[i2]) - == HASH_NAMESPACE::hash_range( + == BOOST_HASH_TEST_NAMESPACE::hash_range( containers[i2].begin(), containers[i2].end())); for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) { diff --git a/test/hash_set_test.cpp b/test/hash_set_test.cpp index 8b5463d..1cf9fef 100644 --- a/test/hash_set_test.cpp +++ b/test/hash_set_test.cpp @@ -5,8 +5,8 @@ #include "./config.hpp" -#ifdef TEST_EXTENSIONS -# ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_EXTENSIONS +# ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else # include @@ -15,7 +15,7 @@ #include -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS #include @@ -31,7 +31,7 @@ using std::multiset; int main() { -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS set_tests::set_hash_integer_tests(); multiset_tests::multiset_hash_integer_tests(); #endif diff --git a/test/hash_set_test.hpp b/test/hash_set_test.hpp index 2a60781..31d4909 100644 --- a/test/hash_set_test.hpp +++ b/test/hash_set_test.hpp @@ -41,16 +41,16 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) containers[11].insert(4); containers[11].insert(5); - HASH_NAMESPACE::hash hasher; + BOOST_HASH_TEST_NAMESPACE::hash hasher; for(int i2 = 0; i2 < number_of_containers; ++i2) { BOOST_TEST(hasher(containers[i2]) == hasher(containers[i2])); BOOST_TEST(hasher(containers[i2]) == - HASH_NAMESPACE::hash_value(containers[i2])); + BOOST_HASH_TEST_NAMESPACE::hash_value(containers[i2])); BOOST_TEST(hasher(containers[i2]) - == HASH_NAMESPACE::hash_range( + == BOOST_HASH_TEST_NAMESPACE::hash_range( containers[i2].begin(), containers[i2].end())); for(int j2 = i2 + 1; j2 < number_of_containers; ++j2) { diff --git a/test/hash_std_array_test.cpp b/test/hash_std_array_test.cpp index 6f67a67..2b240a3 100644 --- a/test/hash_std_array_test.cpp +++ b/test/hash_std_array_test.cpp @@ -5,8 +5,8 @@ #include "./config.hpp" -#ifdef TEST_EXTENSIONS -# ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_EXTENSIONS +# ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else # include @@ -16,7 +16,7 @@ #include #include -#if defined(TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_HDR_ARRAY) +#if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_HDR_ARRAY) #define TEST_ARRAY #include #include diff --git a/test/hash_std_smart_ptr_test.cpp b/test/hash_std_smart_ptr_test.cpp index 7452585..feb09d9 100644 --- a/test/hash_std_smart_ptr_test.cpp +++ b/test/hash_std_smart_ptr_test.cpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else # include @@ -14,7 +14,7 @@ #include #include "./compile_time.hpp" -#if defined(TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_SMART_PTR) +#if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_SMART_PTR) #define TEST_SMART_PTRS #include #endif @@ -26,8 +26,8 @@ void shared_ptr_tests() std::shared_ptr x; compile_time_tests(&x); - HASH_NAMESPACE::hash > x1; - HASH_NAMESPACE::hash > x2; + BOOST_HASH_TEST_NAMESPACE::hash > x1; + BOOST_HASH_TEST_NAMESPACE::hash > x2; std::shared_ptr ptr1(new int(10)); std::shared_ptr ptr2; @@ -39,9 +39,9 @@ void shared_ptr_tests() BOOST_TEST(x1(ptr1) != x2(ptr2)); ptr2 = ptr1; BOOST_TEST(x1(ptr1) == x2(ptr2)); -#if defined(TEST_EXTENSIONS) - BOOST_TEST(x1(x) == HASH_NAMESPACE::hash_value(x)); - BOOST_TEST(x1(ptr1) == HASH_NAMESPACE::hash_value(ptr2)); +#if defined(BOOST_HASH_TEST_EXTENSIONS) + BOOST_TEST(x1(x) == BOOST_HASH_TEST_NAMESPACE::hash_value(x)); + BOOST_TEST(x1(ptr1) == BOOST_HASH_TEST_NAMESPACE::hash_value(ptr2)); #endif } @@ -50,8 +50,8 @@ void unique_ptr_tests() std::unique_ptr x; compile_time_tests(&x); - HASH_NAMESPACE::hash > x1; - HASH_NAMESPACE::hash > x2; + BOOST_HASH_TEST_NAMESPACE::hash > x1; + BOOST_HASH_TEST_NAMESPACE::hash > x2; std::unique_ptr ptr1(new int(10)); std::unique_ptr ptr2; @@ -62,8 +62,8 @@ void unique_ptr_tests() BOOST_TEST(x1(ptr1) == x2(ptr1)); BOOST_TEST(x1(ptr1) != x2(ptr2)); -#if defined(TEST_EXTENSIONS) - BOOST_TEST(x1(x) == HASH_NAMESPACE::hash_value(x)); +#if defined(BOOST_HASH_TEST_EXTENSIONS) + BOOST_TEST(x1(x) == BOOST_HASH_TEST_NAMESPACE::hash_value(x)); #endif } diff --git a/test/hash_std_tuple_test.cpp b/test/hash_std_tuple_test.cpp index 9314336..97bea99 100644 --- a/test/hash_std_tuple_test.cpp +++ b/test/hash_std_tuple_test.cpp @@ -5,8 +5,8 @@ #include "./config.hpp" -#ifdef TEST_EXTENSIONS -# ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_EXTENSIONS +# ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else # include @@ -16,7 +16,7 @@ #include #include -#if defined(TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_HDR_TUPLE) +#if defined(BOOST_HASH_TEST_EXTENSIONS) && !defined(BOOST_NO_CXX11_HDR_TUPLE) #define TEST_TUPLE #include #include diff --git a/test/hash_string_test.cpp b/test/hash_string_test.cpp index 29ff28e..de8ca87 100644 --- a/test/hash_string_test.cpp +++ b/test/hash_string_test.cpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else # include @@ -19,22 +19,22 @@ void string_tests() { compile_time_tests((std::string*) 0); - HASH_NAMESPACE::hash x1; - HASH_NAMESPACE::hash x2; + BOOST_HASH_TEST_NAMESPACE::hash x1; + BOOST_HASH_TEST_NAMESPACE::hash x2; BOOST_TEST(x1("Hello") == x2(std::string("Hel") + "lo")); BOOST_TEST(x1("") == x2(std::string())); -#if defined(TEST_EXTENSIONS) +#if defined(BOOST_HASH_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) == - HASH_NAMESPACE::hash_range(value1.begin(), value1.end())); - BOOST_TEST(HASH_NAMESPACE::hash_value(value2) == - HASH_NAMESPACE::hash_range(value2.begin(), value2.end())); + BOOST_TEST(x1(value1) == BOOST_HASH_TEST_NAMESPACE::hash_value(value1)); + BOOST_TEST(x1(value2) == BOOST_HASH_TEST_NAMESPACE::hash_value(value2)); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(value1) == + BOOST_HASH_TEST_NAMESPACE::hash_range(value1.begin(), value1.end())); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(value2) == + BOOST_HASH_TEST_NAMESPACE::hash_range(value2.begin(), value2.end())); #endif } @@ -43,22 +43,22 @@ void wstring_tests() { compile_time_tests((std::wstring*) 0); - HASH_NAMESPACE::hash x1; - HASH_NAMESPACE::hash x2; + BOOST_HASH_TEST_NAMESPACE::hash x1; + BOOST_HASH_TEST_NAMESPACE::hash x2; BOOST_TEST(x1(L"Hello") == x2(std::wstring(L"Hel") + L"lo")); BOOST_TEST(x1(L"") == x2(std::wstring())); -#if defined(TEST_EXTENSIONS) +#if defined(BOOST_HASH_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) == - HASH_NAMESPACE::hash_range(value1.begin(), value1.end())); - BOOST_TEST(HASH_NAMESPACE::hash_value(value2) == - HASH_NAMESPACE::hash_range(value2.begin(), value2.end())); + BOOST_TEST(x1(value1) == BOOST_HASH_TEST_NAMESPACE::hash_value(value1)); + BOOST_TEST(x1(value2) == BOOST_HASH_TEST_NAMESPACE::hash_value(value2)); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(value1) == + BOOST_HASH_TEST_NAMESPACE::hash_range(value1.begin(), value1.end())); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(value2) == + BOOST_HASH_TEST_NAMESPACE::hash_range(value2.begin(), value2.end())); #endif } #endif diff --git a/test/hash_type_index_test.cpp b/test/hash_type_index_test.cpp index 27fcfff..3288a5b 100644 --- a/test/hash_type_index_test.cpp +++ b/test/hash_type_index_test.cpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_STD_INCLUDES # include #else # include @@ -18,7 +18,7 @@ #include void test_type_index() { - HASH_NAMESPACE::hash hasher; + BOOST_HASH_TEST_NAMESPACE::hash hasher; #if defined(BOOST_NO_TYPEID) std::cout<<"Unable to test std::type_index, as typeid isn't available" @@ -31,9 +31,9 @@ void test_type_index() { BOOST_TEST(hasher(int_index) == int_index.hash_code()); BOOST_TEST(hasher(int_index) == int2_index.hash_code()); BOOST_TEST(hasher(char_index) == char_index.hash_code()); - BOOST_TEST(HASH_NAMESPACE::hash_value(int_index) == int_index.hash_code()); - BOOST_TEST(HASH_NAMESPACE::hash_value(int_index) == int2_index.hash_code()); - BOOST_TEST(HASH_NAMESPACE::hash_value(char_index) == char_index.hash_code()); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(int_index) == int_index.hash_code()); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(int_index) == int2_index.hash_code()); + BOOST_TEST(BOOST_HASH_TEST_NAMESPACE::hash_value(char_index) == char_index.hash_code()); BOOST_TEST(hasher(int_index) == hasher(int2_index)); BOOST_TEST(hasher(int_index) != hasher(char_index)); diff --git a/test/hash_value_array_test.cpp b/test/hash_value_array_test.cpp index 75dfd4f..58fc447 100644 --- a/test/hash_value_array_test.cpp +++ b/test/hash_value_array_test.cpp @@ -8,8 +8,8 @@ #include "./config.hpp" -#ifdef TEST_EXTENSIONS -# ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_EXTENSIONS +# ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else # include @@ -18,7 +18,7 @@ #include -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS void array_int_test() { @@ -29,32 +29,32 @@ void array_int_test() 8, -12, 23, 65, 45, -1, 93, -54, 987, 3 }; - HASH_NAMESPACE::hash hasher1; + BOOST_HASH_TEST_NAMESPACE::hash hasher1; int array2[1] = {3}; - HASH_NAMESPACE::hash hasher2; + BOOST_HASH_TEST_NAMESPACE::hash hasher2; int array3[2] = {2, 3}; - HASH_NAMESPACE::hash hasher3; + BOOST_HASH_TEST_NAMESPACE::hash 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_TEST(hasher1(array1) == BOOST_HASH_TEST_NAMESPACE::hash_value(array1)); + BOOST_TEST(hasher2(array2) == BOOST_HASH_TEST_NAMESPACE::hash_value(array2)); + BOOST_TEST(hasher3(array3) == BOOST_HASH_TEST_NAMESPACE::hash_value(array3)); } void two_dimensional_array_test() { int array[3][2] = {{-5, 6}, {7, -3}, {26, 1}}; - HASH_NAMESPACE::hash hasher; + BOOST_HASH_TEST_NAMESPACE::hash hasher; - BOOST_TEST(hasher(array) == HASH_NAMESPACE::hash_value(array)); + BOOST_TEST(hasher(array) == BOOST_HASH_TEST_NAMESPACE::hash_value(array)); } #endif int main() { -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS array_int_test(); two_dimensional_array_test(); #endif diff --git a/test/hash_vector_test.cpp b/test/hash_vector_test.cpp index de02fe8..6dcf3b0 100644 --- a/test/hash_vector_test.cpp +++ b/test/hash_vector_test.cpp @@ -5,8 +5,8 @@ #include "./config.hpp" -#ifdef TEST_EXTENSIONS -# ifdef TEST_STD_INCLUDES +#ifdef BOOST_HASH_TEST_EXTENSIONS +# ifdef BOOST_HASH_TEST_STD_INCLUDES # include # else # include @@ -15,7 +15,7 @@ #include -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS #include @@ -23,11 +23,11 @@ using std::vector; #define CONTAINER_TYPE vector #include "./hash_sequence_test.hpp" -#endif // TEST_EXTENSIONS +#endif // BOOST_HASH_TEST_EXTENSIONS int main() { -#ifdef TEST_EXTENSIONS +#ifdef BOOST_HASH_TEST_EXTENSIONS vector_tests::vector_hash_integer_tests(); #endif diff --git a/test/link_ext_test.cpp b/test/link_ext_test.cpp index c0e224c..dd895aa 100644 --- a/test/link_ext_test.cpp +++ b/test/link_ext_test.cpp @@ -5,24 +5,24 @@ #include "./config.hpp" -#define HASH_NAMESPACE boost +#define BOOST_HASH_TEST_NAMESPACE boost #include #include #include int f(std::size_t hash1, int* x1) { - // Check that HASH_NAMESPACE::hash works in both files. - HASH_NAMESPACE::hash ptr_hasher; + // Check that BOOST_HASH_TEST_NAMESPACE::hash works in both files. + BOOST_HASH_TEST_NAMESPACE::hash ptr_hasher; BOOST_TEST(hash1 == ptr_hasher(x1)); -#if defined(TEST_EXTENSIONS) +#if defined(BOOST_HASH_TEST_EXTENSIONS) // Check that std::vector is avaiable in this file. std::vector x; x.push_back(*x1); - HASH_NAMESPACE::hash > vector_hasher; - return vector_hasher(x) != HASH_NAMESPACE::hash_value(x); + BOOST_HASH_TEST_NAMESPACE::hash > vector_hasher; + return vector_hasher(x) != BOOST_HASH_TEST_NAMESPACE::hash_value(x); #else diff --git a/test/link_no_ext_test.cpp b/test/link_no_ext_test.cpp index c2e6869..75cd47d 100644 --- a/test/link_no_ext_test.cpp +++ b/test/link_no_ext_test.cpp @@ -5,7 +5,7 @@ #include "./config.hpp" -#define HASH_NAMESPACE boost +#define BOOST_HASH_TEST_NAMESPACE boost #define BOOST_HASH_NO_EXTENSIONS #include #include @@ -13,7 +13,7 @@ extern int f(std::size_t, int*); int main() { - HASH_NAMESPACE::hash ptr_hasher; + BOOST_HASH_TEST_NAMESPACE::hash ptr_hasher; int x = 55; BOOST_TEST(!f(ptr_hasher(&x), &x)); return boost::report_errors(); From e5f3356742bd0d138ec041344aeb417b0bd315b9 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Mon, 17 Dec 2012 23:38:35 +0000 Subject: [PATCH 11/29] Hash: Stop using `-strict-ansi` for Intel. It doesn't seem to be compatible with C++11. [SVN r82060] --- test/Jamfile.v2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 5325b19..2767bf3 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -9,7 +9,7 @@ project hash-tests : requirements all intel:on - intel:-strict-ansi + #intel:-strict-ansi gcc:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow" darwin:"-pedantic -Wstrict-aliasing -fstrict-aliasing -Wextra -Wsign-promo -Wunused-parameter -Wconversion -Wfloat-equal -Wshadow" #msvc:on From 061e0d9d6d33693604abe3e290d0ac5499fca058 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Fri, 21 Dec 2012 09:50:01 +0000 Subject: [PATCH 12/29] Hash: Fix changelog for 1.53.0. [SVN r82140] --- doc/changes.qbk | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/changes.qbk b/doc/changes.qbk index b20e58d..80cb06b 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -142,13 +142,16 @@ [h2 Boost 1.52.0] * Restore `enum` support, which was accidentally removed in the last version. +* New floating point hasher - will hash the binary representation on more + platforms, which should be faster. + +[h2 Boost 1.53.0] + * Add support for `boost::int128_type` and `boost::uint128_type` where available - currently only `__int128` and `unsigned __int128` on some versions of gcc. -* New floating point hasher - will hash the binary representation on more - platforms, which should be faster. -* On platforms that are known to have standard floating point, don't use the - automatic detection of floating point functions - which can break if there - are ambiguous overloads. +* On platforms that are known to have the standard floating point functions, + don't use automatic detection - which can break if there are ambiguous + overloads. [endsect] From 7e162c4f036a19c53a06ea60ecc892ed22cc70cd Mon Sep 17 00:00:00 2001 From: Thomas Heller Date: Thu, 27 Dec 2012 10:49:19 +0000 Subject: [PATCH 13/29] Fixing UB by using memcpy instead of old style cast [SVN r82218] --- include/boost/functional/hash/detail/hash_float.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/boost/functional/hash/detail/hash_float.hpp b/include/boost/functional/hash/detail/hash_float.hpp index 5e20b9c..a98cd70 100644 --- a/include/boost/functional/hash/detail/hash_float.hpp +++ b/include/boost/functional/hash/detail/hash_float.hpp @@ -73,7 +73,9 @@ namespace boost ptr += sizeof(std::size_t); while(length >= sizeof(std::size_t)) { - hash_float_combine(seed, *(std::size_t*) ptr); + std::size_t buffer = 0; + std::memcpy(&buffer, ptr, sizeof(std::size_t)); + hash_float_combine(seed, buffer); length -= sizeof(std::size_t); ptr += sizeof(std::size_t); } From bb8ebafca1f649aec6b91afa146b0f3a9a29a82d Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 29 Dec 2012 11:09:35 +0000 Subject: [PATCH 14/29] Hash: Changelog for undefined behaviour fix. [SVN r82255] --- doc/changes.qbk | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changes.qbk b/doc/changes.qbk index 80cb06b..2334b15 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -153,5 +153,6 @@ * On platforms that are known to have the standard floating point functions, don't use automatic detection - which can break if there are ambiguous overloads. +* Fix undefined behaviour when using the binary float hash (Thomas Heller). [endsect] From 7d148af8d2082eed2345e6dd027f6be48e3e1087 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 31 Jan 2013 21:57:26 +0000 Subject: [PATCH 15/29] Hash: Fix typo, refs #7957. [SVN r82674] --- doc/rationale.qbk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/rationale.qbk b/doc/rationale.qbk index ab03d8b..8621081 100644 --- a/doc/rationale.qbk +++ b/doc/rationale.qbk @@ -38,7 +38,7 @@ function, such as [@http://www.concentric.net/~ttwang/tech/inthash.htm Thomas Wang's hash function]. This this may not work as well as a hash algorithm tailored for the input. -For strings that are several fast, high quality hash functions +For strings there are several fast, high quality hash functions available (for example [@http://code.google.com/p/smhasher/ MurmurHash3] and [@http://code.google.com/p/cityhash/ Google's CityHash]), although they tend to be more machine specific. From 0d6cee7e64b3b875ccfe33a72dd0d70b6366fb50 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 25 May 2013 15:45:51 +0000 Subject: [PATCH 16/29] Change log entries for 1.54.0 [SVN r84496] --- doc/changes.qbk | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/changes.qbk b/doc/changes.qbk index 2334b15..4ca0814 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -155,4 +155,9 @@ overloads. * Fix undefined behaviour when using the binary float hash (Thomas Heller). +[h2 Boost 1.54.0] + +* [@https://svn.boost.org/trac/boost/ticket/7957 Ticket 7957]: + Fixed a typo. + [endsect] From 1870aa9534c2813d6d11840710d6ee50b52b99c4 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 8 Aug 2013 20:30:04 +0000 Subject: [PATCH 17/29] Simpler test for appropriate floats for binary hashing. Refs #8822. No idea if this will actually fix it. [SVN r85246] --- .../functional/hash/detail/hash_float.hpp | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/include/boost/functional/hash/detail/hash_float.hpp b/include/boost/functional/hash/detail/hash_float.hpp index a98cd70..2ac22da 100644 --- a/include/boost/functional/hash/detail/hash_float.hpp +++ b/include/boost/functional/hash/detail/hash_float.hpp @@ -90,15 +90,20 @@ namespace boost return seed; } + template + struct enable_binary_hash + { + BOOST_STATIC_CONSTANT(bool, value = + std::numeric_limits::is_iec559 && + std::numeric_limits::digits == digits && + std::numeric_limits::radix == 2 && + std::numeric_limits::max_exponent == max_exponent); + }; + template inline std::size_t float_hash_impl(Float v, BOOST_DEDUCED_TYPENAME boost::enable_if_c< - std::numeric_limits::is_iec559 && - std::numeric_limits::digits == 24 && - std::numeric_limits::radix == 2 && - std::numeric_limits::max_exponent == 128, - int>::type - ) + enable_binary_hash::value, int>::type) { return hash_binary((char*) &v, 4); } @@ -107,12 +112,7 @@ namespace boost template inline std::size_t float_hash_impl(Float v, BOOST_DEDUCED_TYPENAME boost::enable_if_c< - std::numeric_limits::is_iec559 && - std::numeric_limits::digits == 53 && - std::numeric_limits::radix == 2 && - std::numeric_limits::max_exponent == 1024, - int>::type - ) + enable_binary_hash::value, int>::type) { return hash_binary((char*) &v, 8); } @@ -120,12 +120,7 @@ namespace boost template inline std::size_t float_hash_impl(Float v, BOOST_DEDUCED_TYPENAME boost::enable_if_c< - std::numeric_limits::is_iec559 && - std::numeric_limits::digits == 64 && - std::numeric_limits::radix == 2 && - std::numeric_limits::max_exponent == 16384, - int>::type - ) + enable_binary_hash::value, int>::type) { return hash_binary((char*) &v, 10); } From dea8d12a046efbd3591f1527e05415b7ff63fba2 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Thu, 8 Aug 2013 22:01:18 +0000 Subject: [PATCH 18/29] Fix Visual C++ warning in hash. Refs #8568. I changed this a little from the patch on #8568. I moved the pragmas to the start and end of the file because I don't like to little the body of the code with them (this does mean I've disabled a potentially useful warning, but the code is pretty stable nowadays). I also removed the version checks, as the warning should be present in later versions. [SVN r85248] --- include/boost/functional/hash/hash.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index aa4e49f..0adf9c9 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -27,6 +27,13 @@ #include #endif +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable:6295) // Ill-defined for-loop : 'unsigned int' values + // are always of range '0' to '4294967295'. + // Loop executes infinitely. +#endif + #if BOOST_WORKAROUND(__GNUC__, < 3) \ && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) #define BOOST_HASH_CHAR_TRAITS string_char_traits @@ -518,6 +525,10 @@ namespace boost #undef BOOST_HASH_CHAR_TRAITS +#if defined(BOOST_MSVC) +#pragma warning(pop) +#endif + #endif // BOOST_FUNCTIONAL_HASH_HASH_HPP // Include this outside of the include guards in case the file is included From 378007cf9440f28864ba9829b63e16d89d41b4a3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 26 Sep 2013 13:02:51 +0000 Subject: [PATCH 19/29] Remove obsolete MSVC check from pragma guard git grep -h -B1 "^#\s*pragma once" | grep -v pragma | sort | uniq is now clean. [SVN r85952] --- include/boost/functional/hash/detail/float_functions.hpp | 2 +- include/boost/functional/hash/detail/hash_float.hpp | 2 +- include/boost/functional/hash/detail/limits.hpp | 2 +- include/boost/functional/hash/extensions.hpp | 2 +- include/boost/functional/hash/hash_fwd.hpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/boost/functional/hash/detail/float_functions.hpp b/include/boost/functional/hash/detail/float_functions.hpp index 4b8374d..648b433 100644 --- a/include/boost/functional/hash/detail/float_functions.hpp +++ b/include/boost/functional/hash/detail/float_functions.hpp @@ -9,7 +9,7 @@ #include #include -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif diff --git a/include/boost/functional/hash/detail/hash_float.hpp b/include/boost/functional/hash/detail/hash_float.hpp index 2ac22da..7e71aa0 100644 --- a/include/boost/functional/hash/detail/hash_float.hpp +++ b/include/boost/functional/hash/detail/hash_float.hpp @@ -6,7 +6,7 @@ #if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER) #define BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif diff --git a/include/boost/functional/hash/detail/limits.hpp b/include/boost/functional/hash/detail/limits.hpp index f5b520e..e48b950 100644 --- a/include/boost/functional/hash/detail/limits.hpp +++ b/include/boost/functional/hash/detail/limits.hpp @@ -9,7 +9,7 @@ #if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER) #define BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif diff --git a/include/boost/functional/hash/extensions.hpp b/include/boost/functional/hash/extensions.hpp index 998c08e..76b7d51 100644 --- a/include/boost/functional/hash/extensions.hpp +++ b/include/boost/functional/hash/extensions.hpp @@ -32,7 +32,7 @@ # include #endif -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif diff --git a/include/boost/functional/hash/hash_fwd.hpp b/include/boost/functional/hash/hash_fwd.hpp index 1d51b07..0422efd 100644 --- a/include/boost/functional/hash/hash_fwd.hpp +++ b/include/boost/functional/hash/hash_fwd.hpp @@ -10,7 +10,7 @@ #if !defined(BOOST_FUNCTIONAL_HASH_FWD_HPP) #define BOOST_FUNCTIONAL_HASH_FWD_HPP -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma once #endif From e26c1025227db545900d56b03cd70b7eb8d4a508 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Mon, 30 Sep 2013 11:22:29 +0000 Subject: [PATCH 20/29] Functional: Remove obsolete MSVC version checks. [SVN r86051] --- include/boost/functional/hash/extensions.hpp | 62 -------------------- include/boost/functional/hash/hash.hpp | 45 -------------- include/boost/functional/hash/hash_fwd.hpp | 4 -- 3 files changed, 111 deletions(-) diff --git a/include/boost/functional/hash/extensions.hpp b/include/boost/functional/hash/extensions.hpp index 76b7d51..8b60076 100644 --- a/include/boost/functional/hash/extensions.hpp +++ b/include/boost/functional/hash/extensions.hpp @@ -40,10 +40,6 @@ #include #endif -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) -#include -#endif - namespace boost { template @@ -232,11 +228,7 @@ namespace boost template struct inner { -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) static std::size_t call(Array const& v) -#else - static std::size_t call(Array& v) -#endif { const int size = sizeof(v) / sizeof(*v); return boost::hash_range(v, v + size); @@ -298,8 +290,6 @@ namespace boost template struct hash_impl; -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) - template <> struct hash_impl { @@ -320,58 +310,6 @@ namespace boost #endif }; }; - -#else // Visual C++ 6.5 - - // Visual C++ 6.5 has problems with nested member functions and - // applying const to const types in templates. So we get this: - - template - struct hash_impl_msvc - { - template - struct inner - : public std::unary_function - { - std::size_t operator()(T const& val) const - { - return hash_detail::call_hash::call(val); - } - - std::size_t operator()(T& val) const - { - return hash_detail::call_hash::call(val); - } - }; - }; - - template <> - struct hash_impl_msvc - { - template - struct inner - : public std::unary_function - { - std::size_t operator()(T& val) const - { - return hash_detail::call_hash::call(val); - } - }; - }; - - template - struct hash_impl_msvc2 - : public hash_impl_msvc::value> - ::BOOST_NESTED_TEMPLATE inner {}; - - template <> - struct hash_impl - { - template - struct inner : public hash_impl_msvc2 {}; - }; - -#endif // Visual C++ 6.5 } #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION } diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index 0adf9c9..d8ea415 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -244,13 +244,8 @@ namespace boost #endif #endif -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) - template - inline void hash_combine(std::size_t& seed, T& v) -#else template inline void hash_combine(std::size_t& seed, T const& v) -#endif { boost::hash hasher; seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); @@ -358,7 +353,6 @@ namespace boost // // These are undefined later. -#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) #define BOOST_HASH_SPECIALIZE(type) \ template <> struct hash \ : public std::unary_function \ @@ -378,45 +372,6 @@ namespace boost return boost::hash_value(v); \ } \ }; -#else -#define BOOST_HASH_SPECIALIZE(type) \ - template <> struct hash \ - : public std::unary_function \ - { \ - std::size_t operator()(type v) const \ - { \ - return boost::hash_value(v); \ - } \ - }; \ - \ - template <> struct hash \ - : public std::unary_function \ - { \ - std::size_t operator()(const type v) const \ - { \ - return boost::hash_value(v); \ - } \ - }; - -#define BOOST_HASH_SPECIALIZE_REF(type) \ - template <> struct hash \ - : public std::unary_function \ - { \ - std::size_t operator()(type const& v) const \ - { \ - return boost::hash_value(v); \ - } \ - }; \ - \ - template <> struct hash \ - : public std::unary_function \ - { \ - std::size_t operator()(type const& v) const \ - { \ - return boost::hash_value(v); \ - } \ - }; -#endif BOOST_HASH_SPECIALIZE(bool) BOOST_HASH_SPECIALIZE(char) diff --git a/include/boost/functional/hash/hash_fwd.hpp b/include/boost/functional/hash/hash_fwd.hpp index 0422efd..74dbaf8 100644 --- a/include/boost/functional/hash/hash_fwd.hpp +++ b/include/boost/functional/hash/hash_fwd.hpp @@ -22,11 +22,7 @@ namespace boost { template struct hash; -#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) - template void hash_combine(std::size_t& seed, T& v); -#else template void hash_combine(std::size_t& seed, T const& v); -#endif template std::size_t hash_range(It, It); template void hash_range(std::size_t&, It, It); From af17fa46fbba5f09e4523148a6323555fac282eb Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 1 Oct 2013 08:46:45 +0000 Subject: [PATCH 21/29] Functional: Remove obsolete GCC version checks. [SVN r86112] --- include/boost/functional/hash/hash.hpp | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index d8ea415..0a43139 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -34,13 +34,6 @@ // Loop executes infinitely. #endif -#if BOOST_WORKAROUND(__GNUC__, < 3) \ - && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) -#define BOOST_HASH_CHAR_TRAITS string_char_traits -#else -#define BOOST_HASH_CHAR_TRAITS char_traits -#endif - namespace boost { namespace hash_detail @@ -135,7 +128,7 @@ namespace boost template std::size_t hash_value( - std::basic_string, A> const&); + std::basic_string, A> const&); template typename boost::hash_detail::float_numbers::type hash_value(T); @@ -319,7 +312,7 @@ namespace boost template inline std::size_t hash_value( - std::basic_string, A> const& v) + std::basic_string, A> const& v) { return hash_range(v.begin(), v.end()); } @@ -478,8 +471,6 @@ namespace boost #endif } -#undef BOOST_HASH_CHAR_TRAITS - #if defined(BOOST_MSVC) #pragma warning(pop) #endif From 734eb87d2a8f6cb891cfa5fb6ec0a380c253f7cd Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 6 Oct 2013 08:02:35 +0000 Subject: [PATCH 22/29] Simplify SFINAE for largest float overload. Refs #8822. I accidentally missed it out. Also fix the return values. [SVN r86172] --- .../boost/functional/hash/detail/hash_float.hpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/include/boost/functional/hash/detail/hash_float.hpp b/include/boost/functional/hash/detail/hash_float.hpp index 7e71aa0..b2866f8 100644 --- a/include/boost/functional/hash/detail/hash_float.hpp +++ b/include/boost/functional/hash/detail/hash_float.hpp @@ -103,7 +103,8 @@ namespace boost template inline std::size_t float_hash_impl(Float v, BOOST_DEDUCED_TYPENAME boost::enable_if_c< - enable_binary_hash::value, int>::type) + enable_binary_hash::value, + std::size_t>::type) { return hash_binary((char*) &v, 4); } @@ -112,7 +113,8 @@ namespace boost template inline std::size_t float_hash_impl(Float v, BOOST_DEDUCED_TYPENAME boost::enable_if_c< - enable_binary_hash::value, int>::type) + enable_binary_hash::value, + std::size_t>::type) { return hash_binary((char*) &v, 8); } @@ -120,7 +122,8 @@ namespace boost template inline std::size_t float_hash_impl(Float v, BOOST_DEDUCED_TYPENAME boost::enable_if_c< - enable_binary_hash::value, int>::type) + enable_binary_hash::value, + std::size_t>::type) { return hash_binary((char*) &v, 10); } @@ -128,12 +131,8 @@ namespace boost template inline std::size_t float_hash_impl(Float v, BOOST_DEDUCED_TYPENAME boost::enable_if_c< - std::numeric_limits::is_iec559 && - std::numeric_limits::digits == 113 && - std::numeric_limits::radix == 2 && - std::numeric_limits::max_exponent == 16384, - int>::type - ) + enable_binary_hash::value, + std::size_t>::type) { return hash_binary((char*) &v, 16); } From 10c83e95d976d23e75e5dcfbc08599f7bef75f0f Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 6 Oct 2013 08:03:12 +0000 Subject: [PATCH 23/29] Change log. [SVN r86173] --- doc/changes.qbk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/doc/changes.qbk b/doc/changes.qbk index 4ca0814..c824e1a 100644 --- a/doc/changes.qbk +++ b/doc/changes.qbk @@ -3,6 +3,8 @@ / 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) ] +[template ticket[number]''''''#[number]''''''] + [section:changes Change Log] [h2 Boost 1.33.0] @@ -160,4 +162,11 @@ * [@https://svn.boost.org/trac/boost/ticket/7957 Ticket 7957]: Fixed a typo. +[h2 Boost 1.55.0] + +* Simplify a SFINAE check so that it will hopefully work on Sun 5.9 + ([ticket 8822]). +* Suppress Visual C++ infinite loop warning ([ticket 8568]). + + [endsect] From 999c2d5963014ed68c29445662b12d7f17b39205 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 11 Oct 2013 23:13:10 +0000 Subject: [PATCH 24/29] Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Process #ifdef...#endif blocks. [SVN r86243] --- include/boost/functional/hash/hash.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index 0a43139..6376706 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -19,9 +19,6 @@ #include #include -#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) -#include -#endif #if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) #include From 614feab582f778a79986530640e1cc7ab442df97 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 11 Oct 2013 23:17:48 +0000 Subject: [PATCH 25/29] Remove BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION Process #ifndef...#else...#endif blocks. [SVN r86245] --- include/boost/functional/hash/extensions.hpp | 34 ---------------- include/boost/functional/hash/hash.hpp | 43 -------------------- 2 files changed, 77 deletions(-) diff --git a/include/boost/functional/hash/extensions.hpp b/include/boost/functional/hash/extensions.hpp index 8b60076..e591f99 100644 --- a/include/boost/functional/hash/extensions.hpp +++ b/include/boost/functional/hash/extensions.hpp @@ -250,7 +250,6 @@ namespace boost // -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template struct hash : std::unary_function @@ -279,39 +278,6 @@ namespace boost }; #endif -#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION - - // On compilers without partial specialization, boost::hash - // has already been declared to deal with pointers, so just - // need to supply the non-pointer version of hash_impl. - - namespace hash_detail - { - template - struct hash_impl; - - template <> - struct hash_impl - { - template - struct inner - : std::unary_function - { -#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::call(val); - } -#endif - }; - }; - } -#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION } #endif diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index 6376706..593fde0 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -405,7 +405,6 @@ namespace boost // Specializing boost::hash for pointers. -#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template struct hash @@ -424,48 +423,6 @@ namespace boost } }; -#else - - // For compilers without partial specialization, we define a - // boost::hash for all remaining types. But hash_impl is only defined - // for pointers in 'extensions.hpp' - so when BOOST_HASH_NO_EXTENSIONS - // is defined there will still be a compile error for types not supported - // in the standard. - - namespace hash_detail - { - template - struct hash_impl; - - template <> - struct hash_impl - { - template - struct inner - : public std::unary_function - { - std::size_t operator()(T val) const - { -#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 590) - return boost::hash_value(val); -#else - std::size_t x = static_cast( - reinterpret_cast(val)); - - return x + (x >> 3); -#endif - } - }; - }; - } - - template struct hash - : public boost::hash_detail::hash_impl::value> - ::BOOST_NESTED_TEMPLATE inner - { - }; - -#endif } #if defined(BOOST_MSVC) From 998f714f8f05d0c97fccfd92f39a9126caef4e98 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 10 Nov 2013 23:25:54 +0000 Subject: [PATCH 26/29] Link to archived copy of Thomas Wang's integer hash function. His site's no longer on the web, so use web.archive.org instead. [SVN r86607] --- doc/rationale.qbk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/rationale.qbk b/doc/rationale.qbk index 8621081..76ff6d1 100644 --- a/doc/rationale.qbk +++ b/doc/rationale.qbk @@ -34,7 +34,7 @@ For other use cases, if you do need a higher quality hash function, then neither the standard hash function or `boost::hash` are appropriate. There are several options available. One is to use a second hash on the output of this hash -function, such as [@http://www.concentric.net/~ttwang/tech/inthash.htm +function, such as [@http://web.archive.org/web/20121102023700/http://www.concentric.net/~Ttwang/tech/inthash.htm Thomas Wang's hash function]. This this may not work as well as a hash algorithm tailored for the input. From 74603822f4a522e2c124d324f8be51f9ce32efe3 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 12 Nov 2013 22:09:42 +0000 Subject: [PATCH 27/29] Only use Visual C++ pragma for appropriate versions. [SVN r86671] --- include/boost/functional/hash/hash.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index 593fde0..e1aa245 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -26,11 +26,15 @@ #if defined(BOOST_MSVC) #pragma warning(push) + +#if BOOST_MSVC >= 1400 #pragma warning(disable:6295) // Ill-defined for-loop : 'unsigned int' values // are always of range '0' to '4294967295'. // Loop executes infinitely. #endif +#endif + namespace boost { namespace hash_detail From b066a9c50978343c98381a6e9d06920e469c2905 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sat, 16 Nov 2013 20:13:24 +0000 Subject: [PATCH 28/29] Use `BOOST_HAS_PRAGMA_ONCE`. Remembering to first include config, so that it'll actually be defined. [SVN r86726] --- include/boost/functional/hash/detail/float_functions.hpp | 8 ++++---- include/boost/functional/hash/detail/hash_float.hpp | 6 +++--- include/boost/functional/hash/detail/limits.hpp | 5 +++-- include/boost/functional/hash/extensions.hpp | 9 +++++---- include/boost/functional/hash/hash_fwd.hpp | 6 +++--- include/boost/functional/hash_fwd.hpp | 6 +++++- 6 files changed, 23 insertions(+), 17 deletions(-) diff --git a/include/boost/functional/hash/detail/float_functions.hpp b/include/boost/functional/hash/detail/float_functions.hpp index 648b433..f3db52f 100644 --- a/include/boost/functional/hash/detail/float_functions.hpp +++ b/include/boost/functional/hash/detail/float_functions.hpp @@ -7,12 +7,12 @@ #define BOOST_FUNCTIONAL_HASH_DETAIL_FLOAT_FUNCTIONS_HPP #include -#include - -#if defined(_MSC_VER) -# pragma once +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif +#include + // Set BOOST_HASH_CONFORMANT_FLOATS to 1 for libraries known to have // sufficiently good floating point support to not require any // workarounds. diff --git a/include/boost/functional/hash/detail/hash_float.hpp b/include/boost/functional/hash/detail/hash_float.hpp index b2866f8..ee0ee87 100644 --- a/include/boost/functional/hash/detail/hash_float.hpp +++ b/include/boost/functional/hash/detail/hash_float.hpp @@ -6,11 +6,11 @@ #if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER) #define BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER -#if defined(_MSC_VER) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif -#include #include #include #include diff --git a/include/boost/functional/hash/detail/limits.hpp b/include/boost/functional/hash/detail/limits.hpp index e48b950..4a971a6 100644 --- a/include/boost/functional/hash/detail/limits.hpp +++ b/include/boost/functional/hash/detail/limits.hpp @@ -9,8 +9,9 @@ #if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER) #define BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER -#if defined(_MSC_VER) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif #include diff --git a/include/boost/functional/hash/extensions.hpp b/include/boost/functional/hash/extensions.hpp index e591f99..ba34ca5 100644 --- a/include/boost/functional/hash/extensions.hpp +++ b/include/boost/functional/hash/extensions.hpp @@ -13,6 +13,11 @@ #if !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP) #define BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once +#endif + #include #include #include @@ -32,10 +37,6 @@ # include #endif -#if defined(_MSC_VER) -# pragma once -#endif - #if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) #include #endif diff --git a/include/boost/functional/hash/hash_fwd.hpp b/include/boost/functional/hash/hash_fwd.hpp index 74dbaf8..01fe012 100644 --- a/include/boost/functional/hash/hash_fwd.hpp +++ b/include/boost/functional/hash/hash_fwd.hpp @@ -10,11 +10,11 @@ #if !defined(BOOST_FUNCTIONAL_HASH_FWD_HPP) #define BOOST_FUNCTIONAL_HASH_FWD_HPP -#if defined(_MSC_VER) -# pragma once +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once #endif -#include #include #include diff --git a/include/boost/functional/hash_fwd.hpp b/include/boost/functional/hash_fwd.hpp index b640988..eea9073 100644 --- a/include/boost/functional/hash_fwd.hpp +++ b/include/boost/functional/hash_fwd.hpp @@ -3,5 +3,9 @@ // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -#include +#include +#if defined(BOOST_HAS_PRAGMA_ONCE) +#pragma once +#endif +#include From 7dbc8b593fe3a48cdf9ebb03bf8dabd82a8ad625 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 10 Dec 2013 23:16:40 +0000 Subject: [PATCH 29/29] Revert changes to develop branch. Simplest way to merge to master. --- .../hash/detail/float_functions.hpp | 8 +- .../functional/hash/detail/hash_float.hpp | 6 +- .../boost/functional/hash/detail/limits.hpp | 5 +- include/boost/functional/hash/extensions.hpp | 105 +++++++++++++++++- include/boost/functional/hash/hash.hpp | 104 ++++++++++++++++- include/boost/functional/hash/hash_fwd.hpp | 10 +- include/boost/functional/hash_fwd.hpp | 6 +- 7 files changed, 219 insertions(+), 25 deletions(-) diff --git a/include/boost/functional/hash/detail/float_functions.hpp b/include/boost/functional/hash/detail/float_functions.hpp index f3db52f..4b8374d 100644 --- a/include/boost/functional/hash/detail/float_functions.hpp +++ b/include/boost/functional/hash/detail/float_functions.hpp @@ -7,12 +7,12 @@ #define BOOST_FUNCTIONAL_HASH_DETAIL_FLOAT_FUNCTIONS_HPP #include -#if defined(BOOST_HAS_PRAGMA_ONCE) -#pragma once -#endif - #include +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + // Set BOOST_HASH_CONFORMANT_FLOATS to 1 for libraries known to have // sufficiently good floating point support to not require any // workarounds. diff --git a/include/boost/functional/hash/detail/hash_float.hpp b/include/boost/functional/hash/detail/hash_float.hpp index ee0ee87..7c3de31 100644 --- a/include/boost/functional/hash/detail/hash_float.hpp +++ b/include/boost/functional/hash/detail/hash_float.hpp @@ -6,11 +6,11 @@ #if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER) #define BOOST_FUNCTIONAL_HASH_DETAIL_HASH_FLOAT_HEADER -#include -#if defined(BOOST_HAS_PRAGMA_ONCE) -#pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once #endif +#include #include #include #include diff --git a/include/boost/functional/hash/detail/limits.hpp b/include/boost/functional/hash/detail/limits.hpp index 4a971a6..f5b520e 100644 --- a/include/boost/functional/hash/detail/limits.hpp +++ b/include/boost/functional/hash/detail/limits.hpp @@ -9,9 +9,8 @@ #if !defined(BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER) #define BOOST_FUNCTIONAL_HASH_DETAIL_LIMITS_HEADER -#include -#if defined(BOOST_HAS_PRAGMA_ONCE) -#pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once #endif #include diff --git a/include/boost/functional/hash/extensions.hpp b/include/boost/functional/hash/extensions.hpp index ba34ca5..998c08e 100644 --- a/include/boost/functional/hash/extensions.hpp +++ b/include/boost/functional/hash/extensions.hpp @@ -13,11 +13,6 @@ #if !defined(BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP) #define BOOST_FUNCTIONAL_HASH_EXTENSIONS_HPP -#include -#if defined(BOOST_HAS_PRAGMA_ONCE) -#pragma once -#endif - #include #include #include @@ -37,10 +32,18 @@ # include #endif +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once +#endif + #if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) #include #endif +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) +#include +#endif + namespace boost { template @@ -229,7 +232,11 @@ namespace boost template 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); @@ -251,6 +258,7 @@ namespace boost // +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template struct hash : std::unary_function @@ -279,6 +287,93 @@ namespace boost }; #endif +#else // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION + + // On compilers without partial specialization, boost::hash + // has already been declared to deal with pointers, so just + // need to supply the non-pointer version of hash_impl. + + namespace hash_detail + { + template + struct hash_impl; + +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) + + template <> + struct hash_impl + { + template + struct inner + : std::unary_function + { +#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::call(val); + } +#endif + }; + }; + +#else // Visual C++ 6.5 + + // Visual C++ 6.5 has problems with nested member functions and + // applying const to const types in templates. So we get this: + + template + struct hash_impl_msvc + { + template + struct inner + : public std::unary_function + { + std::size_t operator()(T const& val) const + { + return hash_detail::call_hash::call(val); + } + + std::size_t operator()(T& val) const + { + return hash_detail::call_hash::call(val); + } + }; + }; + + template <> + struct hash_impl_msvc + { + template + struct inner + : public std::unary_function + { + std::size_t operator()(T& val) const + { + return hash_detail::call_hash::call(val); + } + }; + }; + + template + struct hash_impl_msvc2 + : public hash_impl_msvc::value> + ::BOOST_NESTED_TEMPLATE inner {}; + + template <> + struct hash_impl + { + template + struct inner : public hash_impl_msvc2 {}; + }; + +#endif // Visual C++ 6.5 + } +#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION } #endif diff --git a/include/boost/functional/hash/hash.hpp b/include/boost/functional/hash/hash.hpp index e1aa245..42ea019 100644 --- a/include/boost/functional/hash/hash.hpp +++ b/include/boost/functional/hash/hash.hpp @@ -19,6 +19,9 @@ #include #include +#if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) +#include +#endif #if !defined(BOOST_NO_CXX11_HDR_TYPEINDEX) #include @@ -35,6 +38,13 @@ #endif +#if BOOST_WORKAROUND(__GNUC__, < 3) \ + && !defined(__SGI_STL_PORT) && !defined(_STLPORT_VERSION) +#define BOOST_HASH_CHAR_TRAITS string_char_traits +#else +#define BOOST_HASH_CHAR_TRAITS char_traits +#endif + namespace boost { namespace hash_detail @@ -129,7 +139,7 @@ namespace boost template std::size_t hash_value( - std::basic_string, A> const&); + std::basic_string, A> const&); template typename boost::hash_detail::float_numbers::type hash_value(T); @@ -238,8 +248,13 @@ namespace boost #endif #endif +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + template + inline void hash_combine(std::size_t& seed, T& v) +#else template inline void hash_combine(std::size_t& seed, T const& v) +#endif { boost::hash hasher; seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); @@ -313,7 +328,7 @@ namespace boost template inline std::size_t hash_value( - std::basic_string, A> const& v) + std::basic_string, A> const& v) { return hash_range(v.begin(), v.end()); } @@ -347,6 +362,7 @@ namespace boost // // These are undefined later. +#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) #define BOOST_HASH_SPECIALIZE(type) \ template <> struct hash \ : public std::unary_function \ @@ -366,6 +382,45 @@ namespace boost return boost::hash_value(v); \ } \ }; +#else +#define BOOST_HASH_SPECIALIZE(type) \ + template <> struct hash \ + : public std::unary_function \ + { \ + std::size_t operator()(type v) const \ + { \ + return boost::hash_value(v); \ + } \ + }; \ + \ + template <> struct hash \ + : public std::unary_function \ + { \ + std::size_t operator()(const type v) const \ + { \ + return boost::hash_value(v); \ + } \ + }; + +#define BOOST_HASH_SPECIALIZE_REF(type) \ + template <> struct hash \ + : public std::unary_function \ + { \ + std::size_t operator()(type const& v) const \ + { \ + return boost::hash_value(v); \ + } \ + }; \ + \ + template <> struct hash \ + : public std::unary_function \ + { \ + std::size_t operator()(type const& v) const \ + { \ + return boost::hash_value(v); \ + } \ + }; +#endif BOOST_HASH_SPECIALIZE(bool) BOOST_HASH_SPECIALIZE(char) @@ -409,6 +464,7 @@ namespace boost // Specializing boost::hash for pointers. +#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) template struct hash @@ -427,8 +483,52 @@ namespace boost } }; +#else + + // For compilers without partial specialization, we define a + // boost::hash for all remaining types. But hash_impl is only defined + // for pointers in 'extensions.hpp' - so when BOOST_HASH_NO_EXTENSIONS + // is defined there will still be a compile error for types not supported + // in the standard. + + namespace hash_detail + { + template + struct hash_impl; + + template <> + struct hash_impl + { + template + struct inner + : public std::unary_function + { + std::size_t operator()(T val) const + { +#if !BOOST_WORKAROUND(__SUNPRO_CC, <= 590) + return boost::hash_value(val); +#else + std::size_t x = static_cast( + reinterpret_cast(val)); + + return x + (x >> 3); +#endif + } + }; + }; + } + + template struct hash + : public boost::hash_detail::hash_impl::value> + ::BOOST_NESTED_TEMPLATE inner + { + }; + +#endif } +#undef BOOST_HASH_CHAR_TRAITS + #if defined(BOOST_MSVC) #pragma warning(pop) #endif diff --git a/include/boost/functional/hash/hash_fwd.hpp b/include/boost/functional/hash/hash_fwd.hpp index 01fe012..1d51b07 100644 --- a/include/boost/functional/hash/hash_fwd.hpp +++ b/include/boost/functional/hash/hash_fwd.hpp @@ -10,11 +10,11 @@ #if !defined(BOOST_FUNCTIONAL_HASH_FWD_HPP) #define BOOST_FUNCTIONAL_HASH_FWD_HPP -#include -#if defined(BOOST_HAS_PRAGMA_ONCE) -#pragma once +#if defined(_MSC_VER) && (_MSC_VER >= 1020) +# pragma once #endif +#include #include #include @@ -22,7 +22,11 @@ namespace boost { template struct hash; +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300) + template void hash_combine(std::size_t& seed, T& v); +#else template void hash_combine(std::size_t& seed, T const& v); +#endif template std::size_t hash_range(It, It); template void hash_range(std::size_t&, It, It); diff --git a/include/boost/functional/hash_fwd.hpp b/include/boost/functional/hash_fwd.hpp index eea9073..b640988 100644 --- a/include/boost/functional/hash_fwd.hpp +++ b/include/boost/functional/hash_fwd.hpp @@ -3,9 +3,5 @@ // 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 -#if defined(BOOST_HAS_PRAGMA_ONCE) -#pragma once -#endif - #include +