From 173aa87c214acd624d65e4ac8044658725b29a48 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Tue, 19 Dec 2017 17:48:18 +0000 Subject: [PATCH] Manually write out tuple overloads A tad more usable this way. --- hash/test/config.hpp | 4 ++ hash/test/hash_map_test.hpp | 6 +- hash/test/hash_number_test.cpp | 3 +- hash/test/hash_sequence_test.hpp | 6 +- hash/test/hash_set_test.hpp | 6 +- include/boost/functional/hash/extensions.hpp | 73 ++++++++++++++++---- 6 files changed, 70 insertions(+), 28 deletions(-) diff --git a/hash/test/config.hpp b/hash/test/config.hpp index 53edf0a..28b28d4 100644 --- a/hash/test/config.hpp +++ b/hash/test/config.hpp @@ -18,4 +18,8 @@ // before doing anything else. #pragma warning(disable:4201) // nonstandard extension used : // nameless struct/union + #endif + +#define HASH_TEST_CAT(x, y) HASH_TEST_CAT2(x, y) +#define HASH_TEST_CAT2(x, y) x##y diff --git a/hash/test/hash_map_test.hpp b/hash/test/hash_map_test.hpp index 41bb2fa..95ca62c 100644 --- a/hash/test/hash_map_test.hpp +++ b/hash/test/hash_map_test.hpp @@ -7,15 +7,13 @@ #error "CONTAINER_TYPE not defined" #else -#include - #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable:4244) // conversion from 'int' to 'float' #pragma warning(disable:4245) // signed/unsigned mismatch #endif -namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) +namespace HASH_TEST_CAT(CONTAINER_TYPE, _tests) { template void integer_tests(T* = 0) @@ -59,7 +57,7 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) } } - void BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests()) + void HASH_TEST_CAT(CONTAINER_TYPE, _hash_integer_tests()) { integer_tests((CONTAINER_TYPE*) 0); integer_tests((CONTAINER_TYPE*) 0); diff --git a/hash/test/hash_number_test.cpp b/hash/test/hash_number_test.cpp index 2c36513..69fc633 100644 --- a/hash/test/hash_number_test.cpp +++ b/hash/test/hash_number_test.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include @@ -140,7 +139,7 @@ void bool_test() { BOOST_HASH_TEST_NAMESPACE::hash x1; BOOST_HASH_TEST_NAMESPACE::hash x2; - + BOOST_TEST(x1(true) == x2(true)); BOOST_TEST(x1(false) == x2(false)); BOOST_TEST(x1(true) != x2(false)); diff --git a/hash/test/hash_sequence_test.hpp b/hash/test/hash_sequence_test.hpp index 30083f9..3e915f8 100644 --- a/hash/test/hash_sequence_test.hpp +++ b/hash/test/hash_sequence_test.hpp @@ -7,14 +7,12 @@ #error "CONTAINER_TYPE not defined" #else -#include - #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable:4245) // signed/unsigned mismatch #endif -namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) +namespace HASH_TEST_CAT(CONTAINER_TYPE, _tests) { template void integer_tests(T* = 0) @@ -61,7 +59,7 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) } } - void BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests()) + void HASH_TEST_CAT(CONTAINER_TYPE, _hash_integer_tests()) { integer_tests((CONTAINER_TYPE*) 0); integer_tests((CONTAINER_TYPE*) 0); diff --git a/hash/test/hash_set_test.hpp b/hash/test/hash_set_test.hpp index 0a90330..9a77756 100644 --- a/hash/test/hash_set_test.hpp +++ b/hash/test/hash_set_test.hpp @@ -7,14 +7,12 @@ #error "CONTAINER_TYPE not defined" #else -#include - #if defined(BOOST_MSVC) #pragma warning(push) #pragma warning(disable:4245) // signed/unsigned mismatch #endif -namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) +namespace HASH_TEST_CAT(CONTAINER_TYPE, _tests) { template void integer_tests(T* = 0) @@ -64,7 +62,7 @@ namespace BOOST_PP_CAT(CONTAINER_TYPE, _tests) } } - void BOOST_PP_CAT(CONTAINER_TYPE, _hash_integer_tests()) + void HASH_TEST_CAT(CONTAINER_TYPE, _hash_integer_tests()) { integer_tests((CONTAINER_TYPE*) 0); integer_tests((CONTAINER_TYPE*) 0); diff --git a/include/boost/functional/hash/extensions.hpp b/include/boost/functional/hash/extensions.hpp index 13202b8..b1eb199 100644 --- a/include/boost/functional/hash/extensions.hpp +++ b/include/boost/functional/hash/extensions.hpp @@ -5,7 +5,7 @@ // Based on Peter Dimov's proposal // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf -// issue 6.18. +// issue 6.18. // This implements the extensions to the standard. // It's undocumented, so you shouldn't use it.... @@ -22,8 +22,6 @@ #include #include #include -#include -#include #if !defined(BOOST_NO_CXX11_HDR_ARRAY) # include @@ -171,19 +169,66 @@ namespace boost return boost::hash_detail::hash_tuple(v); } -# define BOOST_HASH_TUPLE_F(z, n, _) \ - template< \ - BOOST_PP_ENUM_PARAMS_Z(z, n, typename A) \ - > \ - inline std::size_t hash_value(std::tuple< \ - BOOST_PP_ENUM_PARAMS_Z(z, n, A) \ - > const& v) \ - { \ - return boost::hash_detail::hash_tuple(v); \ + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); + } + + template + inline std::size_t hash_value(std::tuple const& v) + { + return boost::hash_detail::hash_tuple(v); } - BOOST_PP_REPEAT_FROM_TO(1, 11, BOOST_HASH_TUPLE_F, _) -# undef BOOST_HASH_TUPLE_F #endif #endif