From 05b795bc1444b2e4dea948d4c47fb807458728d2 Mon Sep 17 00:00:00 2001 From: LeonineKing1199 Date: Wed, 8 Dec 2021 10:06:01 -0800 Subject: [PATCH 1/4] Remove unnecessary macro for determining which `allocator_traits` implementation is being used --- .../boost/unordered/detail/implementation.hpp | 28 +------------------ test/Jamfile.v2 | 3 +- test/helpers/test.hpp | 2 -- test/unordered/allocator_traits.cpp | 4 +-- test/unordered/minimal_allocator.cpp | 2 +- 5 files changed, 5 insertions(+), 34 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index e95b1d43..a95dde23 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -82,29 +82,6 @@ #define BOOST_UNORDERED_EMPLACE_LIMIT 10 #endif -// BOOST_UNORDERED_USE_ALLOCATOR_TRAITS - Pick which version of -// allocator_traits to use. -// -// 0 = Own partial implementation -// 1 = std::allocator_traits -// 2 = boost::container::allocator_traits - -#if !defined(BOOST_UNORDERED_USE_ALLOCATOR_TRAITS) -#if !defined(BOOST_NO_CXX11_ALLOCATOR) -#define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 1 -#elif defined(BOOST_MSVC) -#if BOOST_MSVC < 1400 -// Use container's allocator_traits for older versions of Visual -// C++ as I don't test with them. -#define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 2 -#endif -#endif -#endif - -#if !defined(BOOST_UNORDERED_USE_ALLOCATOR_TRAITS) -#define BOOST_UNORDERED_USE_ALLOCATOR_TRAITS 0 -#endif - // BOOST_UNORDERED_TUPLE_ARGS // // Maximum number of std::tuple members to support, or 0 if std::tuple @@ -155,10 +132,7 @@ #elif BOOST_COMP_GNUC && BOOST_COMP_GNUC < BOOST_VERSION_NUMBER(4, 7, 0) // Piecewise construction in GCC 4.6 doesn't work for uncopyable types. #define BOOST_UNORDERED_CXX11_CONSTRUCTION 0 -#elif BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 0 && \ - !defined(BOOST_NO_SFINAE_EXPR) -#define BOOST_UNORDERED_CXX11_CONSTRUCTION 1 -#elif BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1 +#elif !defined(BOOST_NO_CXX11_ALLOCATOR) #define BOOST_UNORDERED_CXX11_CONSTRUCTION 1 #endif #endif diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index e91cfc98..0d98abe2 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -29,8 +29,7 @@ test-suite unordered [ run unordered/minimal_allocator.cpp ] [ run unordered/compile_set.cpp ] [ run unordered/compile_map.cpp ] - [ run unordered/compile_map.cpp : : - : BOOST_UNORDERED_USE_ALLOCATOR_TRAITS=0 + [ run unordered/compile_map.cpp : : : : compile_map_unordered_allocator ] [ run unordered/noexcept_tests.cpp ] [ run unordered/link_test_1.cpp unordered/link_test_2.cpp ] diff --git a/test/helpers/test.hpp b/test/helpers/test.hpp index 5534f811..dabd7c24 100644 --- a/test/helpers/test.hpp +++ b/test/helpers/test.hpp @@ -137,8 +137,6 @@ namespace test { << BOOST_UNORDERED_HAVE_PIECEWISE_CONSTRUCT << "\n" \ << "BOOST_UNORDERED_EMPLACE_LIMIT: " << BOOST_UNORDERED_EMPLACE_LIMIT \ << "\n" \ - << "BOOST_UNORDERED_USE_ALLOCATOR_TRAITS: " \ - << BOOST_UNORDERED_USE_ALLOCATOR_TRAITS << "\n" \ << "BOOST_UNORDERED_CXX11_CONSTRUCTION: " \ << BOOST_UNORDERED_CXX11_CONSTRUCTION << "\n\n" \ << std::flush; \ diff --git a/test/unordered/allocator_traits.cpp b/test/unordered/allocator_traits.cpp index ede48476..7e332aab 100644 --- a/test/unordered/allocator_traits.cpp +++ b/test/unordered/allocator_traits.cpp @@ -111,7 +111,7 @@ void test_empty_allocator() { typedef empty_allocator allocator; typedef boost::unordered::detail::allocator_traits traits; -#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1 +#if !defined(BOOST_NO_CXX11_ALLOCATOR) BOOST_STATIC_ASSERT((boost::is_same::type>::value)); #else @@ -153,7 +153,7 @@ void test_allocator1() { typedef allocator1 allocator; typedef boost::unordered::detail::allocator_traits traits; -#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1 +#if !defined(BOOST_NO_CXX11_ALLOCATOR) BOOST_STATIC_ASSERT((boost::is_same::type>::value)); #else diff --git a/test/unordered/minimal_allocator.cpp b/test/unordered/minimal_allocator.cpp index a692443e..bbbb3f1a 100644 --- a/test/unordered/minimal_allocator.cpp +++ b/test/unordered/minimal_allocator.cpp @@ -48,7 +48,7 @@ template void test_simple_allocator() BOOST_STATIC_ASSERT( (boost::is_same::value)); -#if BOOST_UNORDERED_USE_ALLOCATOR_TRAITS == 1 +#if !defined(BOOST_NO_CXX11_ALLOCATOR) BOOST_STATIC_ASSERT((boost::is_same::type>::value)); #else From fefb6ad4c43ba19aba2045c2820e751ecfaa818f Mon Sep 17 00:00:00 2001 From: LeonineKing1199 Date: Wed, 8 Dec 2021 13:59:11 -0800 Subject: [PATCH 2/4] Remove unnecessary expression test mechanisms --- .../boost/unordered/detail/implementation.hpp | 110 ------------------ 1 file changed, 110 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index a95dde23..97922941 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -844,116 +844,6 @@ namespace boost { } } -//////////////////////////////////////////////////////////////////////////// -// Expression test mechanism -// -// When SFINAE expressions are available, define -// BOOST_UNORDERED_HAS_FUNCTION which can check if a function call is -// supported by a class, otherwise define BOOST_UNORDERED_HAS_MEMBER which -// can detect if a class has the specified member, but not that it has the -// correct type, this is good enough for a passable impression of -// allocator_traits. - -#if !defined(BOOST_NO_SFINAE_EXPR) - -namespace boost { - namespace unordered { - namespace detail { - template struct expr_test; - template struct expr_test : T - { - }; - } - } -} - -#define BOOST_UNORDERED_CHECK_EXPRESSION(count, result, expression) \ - template \ - static \ - typename boost::unordered::detail::expr_test::type \ - test(BOOST_PP_CAT(choice, count)) - -#define BOOST_UNORDERED_DEFAULT_EXPRESSION(count, result) \ - template \ - static BOOST_PP_CAT(choice, result)::type test(BOOST_PP_CAT(choice, count)) - -#define BOOST_UNORDERED_HAS_FUNCTION(name, thing, args, _) \ - struct BOOST_PP_CAT(has_, name) \ - { \ - template static char for_expr_test(U const&); \ - BOOST_UNORDERED_CHECK_EXPRESSION( \ - 1, 1, boost::unordered::detail::make().name args); \ - BOOST_UNORDERED_DEFAULT_EXPRESSION(2, 2); \ - \ - enum \ - { \ - value = sizeof(test(choose())) == sizeof(choice1::type) \ - }; \ - } - -#else - -namespace boost { - namespace unordered { - namespace detail { - template struct identity - { - typedef T type; - }; - } - } -} - -#define BOOST_UNORDERED_CHECK_MEMBER(count, result, name, member) \ - \ - typedef \ - typename boost::unordered::detail::identity::type BOOST_PP_CAT( \ - check, count); \ - \ - template struct BOOST_PP_CAT(test, count) \ - { \ - typedef BOOST_PP_CAT(choice, result) type; \ - }; \ - \ - template \ - static typename BOOST_PP_CAT(test, count)<&U::name>::type test( \ - BOOST_PP_CAT(choice, count)) - -#define BOOST_UNORDERED_DEFAULT_MEMBER(count, result) \ - template \ - static BOOST_PP_CAT(choice, result)::type test(BOOST_PP_CAT(choice, count)) - -#define BOOST_UNORDERED_HAS_MEMBER(name) \ - struct BOOST_PP_CAT(has_, name) \ - { \ - struct impl \ - { \ - struct base_mixin \ - { \ - int name; \ - }; \ - struct base : public T, public base_mixin \ - { \ - }; \ - \ - BOOST_UNORDERED_CHECK_MEMBER(1, 1, name, int base_mixin::*); \ - BOOST_UNORDERED_DEFAULT_MEMBER(2, 2); \ - \ - enum \ - { \ - value = sizeof(choice2::type) == sizeof(test(choose())) \ - }; \ - }; \ - \ - enum \ - { \ - value = impl::value \ - }; \ - } - -#endif - //////////////////////////////////////////////////////////////////////////// // TRAITS TYPE DETECTION MECHANISM // From 089d2db1048861912eb50cfcb4b51d13eeffa0de Mon Sep 17 00:00:00 2001 From: LeonineKing1199 Date: Wed, 8 Dec 2021 14:04:04 -0800 Subject: [PATCH 3/4] Remove traits detection mechanism --- .../boost/unordered/detail/implementation.hpp | 72 ------------------- 1 file changed, 72 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 97922941..b65d4bc0 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -844,78 +844,6 @@ namespace boost { } } -//////////////////////////////////////////////////////////////////////////// -// TRAITS TYPE DETECTION MECHANISM -// -// Used to implement traits that use a type if present, or a -// default otherwise. - -#if defined(BOOST_MSVC) && BOOST_MSVC <= 1400 - -#define BOOST_UNORDERED_DEFAULT_TYPE_TMPLT(tname) \ - template struct default_type_##tname \ - { \ - \ - template \ - static choice1::type test(choice1, typename X::tname* = 0); \ - \ - template static choice2::type test(choice2, void* = 0); \ - \ - struct DefaultWrap \ - { \ - typedef Default tname; \ - }; \ - \ - enum \ - { \ - value = (1 == sizeof(test(choose()))) \ - }; \ - \ - typedef typename boost::detail::if_true::BOOST_NESTED_TEMPLATE \ - then::type::tname type; \ - } - -#else - -namespace boost { - namespace unordered { - namespace detail { - template struct sfinae : T2 - { - }; - } - } -} - -#define BOOST_UNORDERED_DEFAULT_TYPE_TMPLT(tname) \ - template struct default_type_##tname \ - { \ - \ - template \ - static typename boost::unordered::detail::sfinae::type test(choice1); \ - \ - template static choice2::type test(choice2); \ - \ - struct DefaultWrap \ - { \ - typedef Default tname; \ - }; \ - \ - enum \ - { \ - value = (1 == sizeof(test(choose()))) \ - }; \ - \ - typedef typename boost::detail::if_true::BOOST_NESTED_TEMPLATE \ - then::type::tname type; \ - } - -#endif - -#define BOOST_UNORDERED_DEFAULT_TYPE(T, tname, arg) \ - typename default_type_##tname::type - //////////////////////////////////////////////////////////////////////////////// // // Allocator traits From 4f88b3865f4b5843bdd13f432a2041bbc277f80c Mon Sep 17 00:00:00 2001 From: LeonineKing1199 Date: Wed, 8 Dec 2021 14:15:22 -0800 Subject: [PATCH 4/4] Remove unnecessary test --- test/Jamfile.v2 | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 0d98abe2..4120e0aa 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -29,8 +29,6 @@ test-suite unordered [ run unordered/minimal_allocator.cpp ] [ run unordered/compile_set.cpp ] [ run unordered/compile_map.cpp ] - [ run unordered/compile_map.cpp : : : - : compile_map_unordered_allocator ] [ run unordered/noexcept_tests.cpp ] [ run unordered/link_test_1.cpp unordered/link_test_2.cpp ] [ run unordered/incomplete_test.cpp ]