From 59a7fa09baf8fdee081ef005855218c2ab146fa5 Mon Sep 17 00:00:00 2001 From: Christian Mazakas Date: Tue, 29 Aug 2023 09:53:40 -0700 Subject: [PATCH] Remove usage of BOOST_NO_CXX11_HDR_TYPE_TRAITS --- .../boost/unordered/detail/implementation.hpp | 74 +++++-------------- include/boost/unordered/unordered_map.hpp | 39 +++------- include/boost/unordered/unordered_set.hpp | 44 +++-------- 3 files changed, 40 insertions(+), 117 deletions(-) diff --git a/include/boost/unordered/detail/implementation.hpp b/include/boost/unordered/detail/implementation.hpp index 8e0e6e1d..6483ad74 100644 --- a/include/boost/unordered/detail/implementation.hpp +++ b/include/boost/unordered/detail/implementation.hpp @@ -60,9 +60,7 @@ #include #include -#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) #include -#endif #if BOOST_UNORDERED_CXX11_CONSTRUCTION #include @@ -369,33 +367,6 @@ namespace boost { namespace unordered { namespace detail { - //////////////////////////////////////////////////////////////////////////// - // Integral_constrant, true_type, false_type - // - // Uses the standard versions if available. - -#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS) - - using std::false_type; - using std::integral_constant; - using std::true_type; - -#else - - template struct integral_constant - { - enum - { - value = Value - }; - }; - - typedef boost::unordered::detail::integral_constant true_type; - typedef boost::unordered::detail::integral_constant - false_type; - -#endif - //////////////////////////////////////////////////////////////////////////// // Explicitly call a destructor @@ -1357,8 +1328,7 @@ namespace boost { : current_(0) { construct_functions(current_, bf.current_functions(), - boost::unordered::detail::integral_constant()); + std::integral_constant()); } ~functions() @@ -1414,16 +1384,15 @@ namespace boost { new ((void*)&funcs_[which]) function_pair(hf, eq); } - void construct_functions(unsigned char which, function_pair const& f, - boost::unordered::detail::false_type = - boost::unordered::detail::false_type()) + void construct_functions( + unsigned char which, function_pair const& f, std::false_type = {}) { BOOST_ASSERT(!(which & 2)); new ((void*)&funcs_[which]) function_pair(f); } - void construct_functions(unsigned char which, function_pair& f, - boost::unordered::detail::true_type) + void construct_functions( + unsigned char which, function_pair& f, std::true_type) { BOOST_ASSERT(!(which & 2)); new ((void*)&funcs_[which]) @@ -1922,7 +1891,7 @@ namespace boost { //////////////////////////////////////////////////////////////////////// // Swap and Move - void swap_allocators(table& other, false_type) + void swap_allocators(table& other, std::false_type) { boost::unordered::detail::func::ignore_unused_variable_warning(other); @@ -1933,7 +1902,7 @@ namespace boost { } // Not nothrow swappable - void swap(table& x, false_type) + void swap(table& x, std::false_type) { if (this == &x) { return; @@ -1957,7 +1926,7 @@ namespace boost { } // Nothrow swappable - void swap(table& x, true_type) + void swap(table& x, std::true_type) { buckets_.swap(x.buckets_); boost::core::invoke_swap(size_, x.size_); @@ -1974,8 +1943,7 @@ namespace boost { BOOST_ASSERT(boost::allocator_propagate_on_container_swap< node_allocator_type>::type::value || node_alloc() == x.node_alloc()); - swap(x, boost::unordered::detail::integral_constant()); + swap(x, std::integral_constant()); } // Only call with nodes allocated with the currect allocator, or @@ -2066,14 +2034,12 @@ namespace boost { node_allocator_type>::type pocca; if (this != &x) { - assign(x, is_unique, - boost::unordered::detail::integral_constant()); + assign(x, is_unique, std::integral_constant()); } } template - void assign(table const& x, UniqueType is_unique, false_type) + void assign(table const& x, UniqueType is_unique, std::false_type) { // Strong exception safety. this->construct_spare_functions(x.current_functions()); @@ -2096,11 +2062,11 @@ namespace boost { } template - void assign(table const& x, UniqueType is_unique, true_type) + void assign(table const& x, UniqueType is_unique, std::true_type) { if (node_alloc() == x.node_alloc()) { buckets_.reset_allocator(x.node_alloc()); - assign(x, is_unique, false_type()); + assign(x, is_unique, std::false_type()); } else { bucket_array_type new_buckets(x.size_, x.node_alloc()); this->construct_spare_functions(x.current_functions()); @@ -2128,7 +2094,7 @@ namespace boost { { if (this != &x) { move_assign(x, is_unique, - boost::unordered::detail::integral_constant::type::value>()); } @@ -2136,7 +2102,7 @@ namespace boost { // Propagate allocator template - void move_assign(table& x, UniqueType, true_type) + void move_assign(table& x, UniqueType, std::true_type) { if (!functions::nothrow_move_assignable) { this->construct_spare_functions(x.current_functions()); @@ -2153,7 +2119,7 @@ namespace boost { // Don't propagate allocator template - void move_assign(table& x, UniqueType is_unique, false_type) + void move_assign(table& x, UniqueType is_unique, std::false_type) { if (node_alloc() == x.node_alloc()) { move_assign_equal_alloc(x); @@ -2789,7 +2755,7 @@ namespace boost { //////////////////////////////////////////////////////////////////////// // fill_buckets_unique - void copy_buckets(table const& src, true_type) + void copy_buckets(table const& src, std::true_type) { BOOST_ASSERT(size_ == 0); @@ -2810,7 +2776,7 @@ namespace boost { } } - void move_assign_buckets(table& src, true_type) + void move_assign_buckets(table& src, std::true_type) { BOOST_ASSERT(size_ == 0); BOOST_ASSERT(max_load_ >= src.size_); @@ -3135,7 +3101,7 @@ namespace boost { //////////////////////////////////////////////////////////////////////// // fill_buckets - void copy_buckets(table const& src, false_type) + void copy_buckets(table const& src, std::false_type) { BOOST_ASSERT(size_ == 0); @@ -3156,7 +3122,7 @@ namespace boost { } } - void move_assign_buckets(table& src, false_type) + void move_assign_buckets(table& src, std::false_type) { BOOST_ASSERT(size_ == 0); BOOST_ASSERT(max_load_ >= src.size_); diff --git a/include/boost/unordered/unordered_map.hpp b/include/boost/unordered/unordered_map.hpp index 7408f0e9..74666dcd 100644 --- a/include/boost/unordered/unordered_map.hpp +++ b/include/boost/unordered/unordered_map.hpp @@ -149,7 +149,7 @@ namespace boost { #if defined(BOOST_UNORDERED_USE_MOVE) unordered_map& operator=(BOOST_COPY_ASSIGN_REF(unordered_map) x) { - table_.assign(x.table_, boost::unordered::detail::true_type()); + table_.assign(x.table_, std::true_type()); return *this; } @@ -158,13 +158,13 @@ namespace boost { boost::is_nothrow_move_assignable::value&& boost::is_nothrow_move_assignable

::value) { - table_.move_assign(x.table_, boost::unordered::detail::true_type()); + table_.move_assign(x.table_, std::true_type()); return *this; } #else unordered_map& operator=(unordered_map const& x) { - table_.assign(x.table_, boost::unordered::detail::true_type()); + table_.assign(x.table_, std::true_type()); return *this; } @@ -174,7 +174,7 @@ namespace boost { boost::is_nothrow_move_assignable::value&& boost::is_nothrow_move_assignable

::value) { - table_.move_assign(x.table_, boost::unordered::detail::true_type()); + table_.move_assign(x.table_, std::true_type()); return *this; } #endif @@ -1247,39 +1247,20 @@ namespace boost { // Assign -#if defined(BOOST_UNORDERED_USE_MOVE) - unordered_multimap& operator=(BOOST_COPY_ASSIGN_REF(unordered_multimap) x) - { - table_.assign(x.table_, boost::unordered::detail::false_type()); - return *this; - } - - unordered_multimap& operator=(BOOST_RV_REF(unordered_multimap) x) - noexcept(value_allocator_traits::is_always_equal::value&& - boost::is_nothrow_move_assignable::value&& - boost::is_nothrow_move_assignable

::value) - { - table_.move_assign(x.table_, boost::unordered::detail::false_type()); - return *this; - } -#else unordered_multimap& operator=(unordered_multimap const& x) { - table_.assign(x.table_, boost::unordered::detail::false_type()); + table_.assign(x.table_, std::false_type()); return *this; } -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) unordered_multimap& operator=(unordered_multimap&& x) noexcept(value_allocator_traits::is_always_equal::value&& boost::is_nothrow_move_assignable::value&& boost::is_nothrow_move_assignable

::value) { - table_.move_assign(x.table_, boost::unordered::detail::false_type()); + table_.move_assign(x.table_, std::false_type()); return *this; } -#endif -#endif unordered_multimap& operator=(std::initializer_list); @@ -1869,7 +1850,7 @@ namespace boost { { if (other.size()) { table_.copy_buckets( - other.table_, boost::unordered::detail::true_type()); + other.table_, std::true_type()); } } @@ -1887,7 +1868,7 @@ namespace boost { { if (other.table_.size_) { table_.copy_buckets( - other.table_, boost::unordered::detail::true_type()); + other.table_, std::true_type()); } } @@ -2402,7 +2383,7 @@ namespace boost { { if (other.table_.size_) { table_.copy_buckets( - other.table_, boost::unordered::detail::false_type()); + other.table_, std::false_type()); } } @@ -2421,7 +2402,7 @@ namespace boost { { if (other.table_.size_) { table_.copy_buckets( - other.table_, boost::unordered::detail::false_type()); + other.table_, std::false_type()); } } diff --git a/include/boost/unordered/unordered_set.hpp b/include/boost/unordered/unordered_set.hpp index fe71383e..f7ec58f7 100644 --- a/include/boost/unordered/unordered_set.hpp +++ b/include/boost/unordered/unordered_set.hpp @@ -147,7 +147,7 @@ namespace boost { #if defined(BOOST_UNORDERED_USE_MOVE) unordered_set& operator=(BOOST_COPY_ASSIGN_REF(unordered_set) x) { - table_.assign(x.table_, boost::unordered::detail::true_type()); + table_.assign(x.table_, std::true_type()); return *this; } @@ -156,13 +156,13 @@ namespace boost { boost::is_nothrow_move_assignable::value&& boost::is_nothrow_move_assignable

::value) { - table_.move_assign(x.table_, boost::unordered::detail::true_type()); + table_.move_assign(x.table_, std::true_type()); return *this; } #else unordered_set& operator=(unordered_set const& x) { - table_.assign(x.table_, boost::unordered::detail::true_type()); + table_.assign(x.table_, std::true_type()); return *this; } @@ -172,7 +172,7 @@ namespace boost { boost::is_nothrow_move_assignable::value&& boost::is_nothrow_move_assignable

::value) { - table_.move_assign(x.table_, boost::unordered::detail::true_type()); + table_.move_assign(x.table_, std::true_type()); return *this; } #endif @@ -818,40 +818,20 @@ namespace boost { ~unordered_multiset() noexcept; // Assign - -#if defined(BOOST_UNORDERED_USE_MOVE) - unordered_multiset& operator=(BOOST_COPY_ASSIGN_REF(unordered_multiset) x) - { - table_.assign(x.table_, boost::unordered::detail::false_type()); - return *this; - } - - unordered_multiset& operator=(BOOST_RV_REF(unordered_multiset) x) - noexcept(value_allocator_traits::is_always_equal::value&& - boost::is_nothrow_move_assignable::value&& - boost::is_nothrow_move_assignable

::value) - { - table_.move_assign(x.table_, boost::unordered::detail::false_type()); - return *this; - } -#else unordered_multiset& operator=(unordered_multiset const& x) { - table_.assign(x.table_, boost::unordered::detail::false_type()); + table_.assign(x.table_, std::false_type()); return *this; } -#if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES) unordered_multiset& operator=(unordered_multiset&& x) noexcept(value_allocator_traits::is_always_equal::value&& boost::is_nothrow_move_assignable::value&& boost::is_nothrow_move_assignable

::value) { - table_.move_assign(x.table_, boost::unordered::detail::false_type()); + table_.move_assign(x.table_, std::false_type()); return *this; } -#endif -#endif unordered_multiset& operator=(std::initializer_list); @@ -1389,8 +1369,7 @@ namespace boost { select_on_container_copy_construction(other.get_allocator())) { if (other.size()) { - table_.copy_buckets( - other.table_, boost::unordered::detail::true_type()); + table_.copy_buckets(other.table_, std::true_type()); } } @@ -1407,8 +1386,7 @@ namespace boost { : table_(other.table_, a) { if (other.table_.size_) { - table_.copy_buckets( - other.table_, boost::unordered::detail::true_type()); + table_.copy_buckets(other.table_, std::true_type()); } } @@ -1793,8 +1771,7 @@ namespace boost { select_on_container_copy_construction(other.get_allocator())) { if (other.table_.size_) { - table_.copy_buckets( - other.table_, boost::unordered::detail::false_type()); + table_.copy_buckets(other.table_, std::false_type()); } } @@ -1811,8 +1788,7 @@ namespace boost { : table_(other.table_, a) { if (other.table_.size_) { - table_.copy_buckets( - other.table_, boost::unordered::detail::false_type()); + table_.copy_buckets(other.table_, std::false_type()); } }