forked from boostorg/container
Use boost::adl_move_swap instead of custom swap or std::swap for performance and compatibility reasons.
This commit is contained in:
1 parent
afd1c2d266
commit
32418cab5f
11 files changed
+39
-81
No files matched your search
@@ -28,6 +28,7 @@
|
||||
#include <boost/container/detail/multiallocation_chain.hpp>
|
||||
#include <boost/container/throw_exception.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/adl_move_swap.hpp>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
@@ -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)
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/container/detail/utilities.hpp>
|
||||
#include <boost/container/detail/version_type.hpp>
|
||||
#include <boost/move/adl_move_swap.hpp>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
@@ -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
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <cstddef>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/move/utility_core.hpp>
|
||||
#include <boost/move/adl_move_swap.hpp>
|
||||
#include <memory>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user