diff --git a/include/boost/container/deque.hpp b/include/boost/container/deque.hpp index adf7e63..1e8d9b1 100644 --- a/include/boost/container/deque.hpp +++ b/include/boost/container/deque.hpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -355,10 +356,10 @@ class deque_base void swap_members(deque_base &x) BOOST_CONTAINER_NOEXCEPT { - ::boost::container::swap_dispatch(this->members_.m_start, x.members_.m_start); - ::boost::container::swap_dispatch(this->members_.m_finish, x.members_.m_finish); - ::boost::container::swap_dispatch(this->members_.m_map, x.members_.m_map); - ::boost::container::swap_dispatch(this->members_.m_map_size, x.members_.m_map_size); + ::boost::adl_move_swap(this->members_.m_start, x.members_.m_start); + ::boost::adl_move_swap(this->members_.m_finish, x.members_.m_finish); + ::boost::adl_move_swap(this->members_.m_map, x.members_.m_map); + ::boost::adl_move_swap(this->members_.m_map_size, x.members_.m_map_size); } void priv_initialize_map(size_type num_elements) diff --git a/include/boost/container/detail/flat_tree.hpp b/include/boost/container/detail/flat_tree.hpp index e0ab7c2..e066a0c 100644 --- a/include/boost/container/detail/flat_tree.hpp +++ b/include/boost/container/detail/flat_tree.hpp @@ -36,6 +36,7 @@ #endif #include #include +#include #include //std::pair @@ -159,7 +160,7 @@ class flat_tree void swap(Data &d) { value_compare& mycomp = *this, & othercomp = d; - boost::container::swap_dispatch(mycomp, othercomp); + boost::adl_move_swap(mycomp, othercomp); this->m_vect.swap(d.m_vect); } diff --git a/include/boost/container/detail/memory_util.hpp b/include/boost/container/detail/memory_util.hpp index 2818044..34e931b 100644 --- a/include/boost/container/detail/memory_util.hpp +++ b/include/boost/container/detail/memory_util.hpp @@ -57,12 +57,6 @@ #endif #include BOOST_PP_ITERATE() -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME swap -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEGIN namespace boost { namespace container { namespace container_detail { -#define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}} -#define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 1, )) -#include BOOST_PP_ITERATE() - namespace boost { namespace container { namespace container_detail { diff --git a/include/boost/container/detail/utilities.hpp b/include/boost/container/detail/utilities.hpp index d2fe5c4..fc56350 100644 --- a/include/boost/container/detail/utilities.hpp +++ b/include/boost/container/detail/utilities.hpp @@ -40,10 +40,10 @@ #include #include #include -#include #include #include +#include namespace boost { namespace container { @@ -54,51 +54,6 @@ namespace container { // ////////////////////////////////////////////////////////////////////////////// -namespace container_swap { - -template::value > -struct has_member_swap -{ - static const bool value = boost::container::container_detail:: - has_member_function_callable_with_swap::value; -}; - -template -struct has_member_swap -{ - static const bool value = false; -}; - -} //namespace container_swap { - -template inline -typename container_detail::enable_if_c - ::value, void>::type -swap_dispatch(T &left, T &right) //swap using member swap -{ - left.swap(right); // may throw -} - -template inline -typename container_detail::enable_if_c - ::value/* && boost::has_move_emulation_enabled::value*/, void>::type - swap_dispatch(T &left, T &right) -{ - T temp(boost::move(left)); // may throw - left = boost::move(right); // may throw - right = boost::move(temp); // may throw -} -/* -template inline -typename container_detail::enable_if_c - ::value && !boost::has_move_emulation_enabled::value, void>::type - swap_dispatch(T &left, T &right) -{ - using std::swap; - swap(left, right); // may throw -} -*/ - namespace container_detail { template @@ -194,7 +149,7 @@ inline void swap_alloc(AllocatorType &, AllocatorType &, container_detail::false template inline void swap_alloc(AllocatorType &l, AllocatorType &r, container_detail::true_type) -{ boost::container::swap_dispatch(l, r); } +{ boost::adl_move_swap(l, r); } template inline void assign_alloc(AllocatorType &, const AllocatorType &, container_detail::false_type) @@ -1102,7 +1057,7 @@ inline typename container_detail::disable_if_memtransfer_copy_assignable::size_type n = 0; for (; n != n_i ; ++short_range_f, ++large_range_f, ++n){ - boost::container::swap_dispatch(*short_range_f, *large_range_f); + boost::adl_move_swap(*short_range_f, *large_range_f); } boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i); diff --git a/include/boost/container/scoped_allocator.hpp b/include/boost/container/scoped_allocator.hpp index 0a29871..92ad547 100644 --- a/include/boost/container/scoped_allocator.hpp +++ b/include/boost/container/scoped_allocator.hpp @@ -32,6 +32,7 @@ #include #include #include +#include namespace boost { namespace container { @@ -668,8 +669,8 @@ class scoped_allocator_adaptor_base void swap(scoped_allocator_adaptor_base &r) { - boost::container::swap_dispatch(this->outer_allocator(), r.outer_allocator()); - boost::container::swap_dispatch(this->m_inner, r.inner_allocator()); + boost::adl_move_swap(this->outer_allocator(), r.outer_allocator()); + boost::adl_move_swap(this->m_inner, r.inner_allocator()); } friend void swap(scoped_allocator_adaptor_base &l, scoped_allocator_adaptor_base &r) @@ -839,8 +840,8 @@ class scoped_allocator_adaptor_baseouter_allocator(), r.outer_allocator()); \ - boost::container::swap_dispatch(this->m_inner, r.inner_allocator()); \ + boost::adl_move_swap(this->outer_allocator(), r.outer_allocator()); \ + boost::adl_move_swap(this->m_inner, r.inner_allocator()); \ } \ \ friend void swap(scoped_allocator_adaptor_base &l, scoped_allocator_adaptor_base &r) \ @@ -976,7 +977,7 @@ class scoped_allocator_adaptor_base void swap(scoped_allocator_adaptor_base &r) { - boost::container::swap_dispatch(this->outer_allocator(), r.outer_allocator()); + boost::adl_move_swap(this->outer_allocator(), r.outer_allocator()); } friend void swap(scoped_allocator_adaptor_base &l, scoped_allocator_adaptor_base &r) diff --git a/include/boost/container/stable_vector.hpp b/include/boost/container/stable_vector.hpp index 12bbe24..6acc335 100644 --- a/include/boost/container/stable_vector.hpp +++ b/include/boost/container/stable_vector.hpp @@ -43,6 +43,7 @@ #include #include #include +#include #include //std::pair @@ -1911,7 +1912,7 @@ class stable_vector void priv_swap_members(stable_vector &x) { - boost::container::swap_dispatch(this->internal_data.pool_size, x.internal_data.pool_size); + boost::adl_move_swap(this->internal_data.pool_size, x.internal_data.pool_size); index_traits_type::readjust_end_node(this->index, this->internal_data.end_node); index_traits_type::readjust_end_node(x.index, x.internal_data.end_node); } diff --git a/include/boost/container/string.hpp b/include/boost/container/string.hpp index 895278d..43a726b 100644 --- a/include/boost/container/string.hpp +++ b/include/boost/container/string.hpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -433,7 +434,7 @@ class basic_string_base this->members_.m_repr.short_repr() = short_backup; } else{ - boost::container::swap_dispatch(this->members_.m_repr.long_repr(), other.members_.m_repr.long_repr()); + boost::adl_move_swap(this->members_.m_repr.long_repr(), other.members_.m_repr.long_repr()); } } } diff --git a/include/boost/container/vector.hpp b/include/boost/container/vector.hpp index fb84662..431a921 100644 --- a/include/boost/container/vector.hpp +++ b/include/boost/container/vector.hpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include @@ -363,9 +364,9 @@ struct vector_alloc_holder void swap(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT { - boost::container::swap_dispatch(this->m_start, x.m_start); - boost::container::swap_dispatch(this->m_size, x.m_size); - boost::container::swap_dispatch(this->m_capacity, x.m_capacity); + boost::adl_move_swap(this->m_start, x.m_start); + boost::adl_move_swap(this->m_size, x.m_size); + boost::adl_move_swap(this->m_capacity, x.m_capacity); } void move_from_empty(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT @@ -515,7 +516,7 @@ struct vector_alloc_holder(this->alloc(), first_x, x.m_size, first_this, this->m_size); } - boost::container::swap_dispatch(this->m_size, x.m_size); + boost::adl_move_swap(this->m_size, x.m_size); } }; diff --git a/test/dummy_test_allocator.hpp b/test/dummy_test_allocator.hpp index 3ecfc98..27b5202 100644 --- a/test/dummy_test_allocator.hpp +++ b/test/dummy_test_allocator.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -314,12 +315,12 @@ class propagation_test_allocator void swap(propagation_test_allocator &r) { ++this->swaps_; ++r.swaps_; - boost::container::swap_dispatch(this->id_, r.id_); - boost::container::swap_dispatch(this->ctr_copies_, r.ctr_copies_); - boost::container::swap_dispatch(this->ctr_moves_, r.ctr_moves_); - boost::container::swap_dispatch(this->assign_copies_, r.assign_copies_); - boost::container::swap_dispatch(this->assign_moves_, r.assign_moves_); - boost::container::swap_dispatch(this->swaps_, r.swaps_); + boost::adl_move_swap(this->id_, r.id_); + boost::adl_move_swap(this->ctr_copies_, r.ctr_copies_); + boost::adl_move_swap(this->ctr_moves_, r.ctr_moves_); + boost::adl_move_swap(this->assign_copies_, r.assign_copies_); + boost::adl_move_swap(this->assign_moves_, r.assign_moves_); + boost::adl_move_swap(this->swaps_, r.swaps_); } friend void swap(propagation_test_allocator &l, propagation_test_allocator &r) diff --git a/test/expand_bwd_test_allocator.hpp b/test/expand_bwd_test_allocator.hpp index f7ba304..3ae6ffb 100644 --- a/test/expand_bwd_test_allocator.hpp +++ b/test/expand_bwd_test_allocator.hpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -109,9 +110,9 @@ class expand_bwd_test_allocator friend void swap(self_t &alloc1, self_t &alloc2) { - boost::container::swap_dispatch(alloc1.mp_buffer, alloc2.mp_buffer); - boost::container::swap_dispatch(alloc1.m_size, alloc2.m_size); - boost::container::swap_dispatch(alloc1.m_offset, alloc2.m_offset); + boost::adl_move_swap(alloc1.mp_buffer, alloc2.mp_buffer); + boost::adl_move_swap(alloc1.m_size, alloc2.m_size); + boost::adl_move_swap(alloc1.m_offset, alloc2.m_offset); } //Experimental version 2 expand_bwd_test_allocator functions diff --git a/test/scoped_allocator_adaptor_test.cpp b/test/scoped_allocator_adaptor_test.cpp index dadeba6..d86359b 100644 --- a/test/scoped_allocator_adaptor_test.cpp +++ b/test/scoped_allocator_adaptor_test.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include using namespace boost::container; @@ -475,8 +476,8 @@ int main() { Scoped0Inner s0i2; Scoped1Inner s1i2; - boost::container::swap_dispatch(s0i, s0i2); - boost::container::swap_dispatch(s1i, s1i2); + boost::adl_move_swap(s0i, s0i2); + boost::adl_move_swap(s1i, s1i2); } }