Fixes #88 ("Implement C++17 MoveAssignable requirements for self-move assignments")

This commit is contained in:
Ion Gaztañaga
2019-04-30 18:05:50 +02:00
parent 909ccf6057
commit 5f0ce60b39
7 changed files with 151 additions and 146 deletions

View File

@@ -1267,7 +1267,7 @@ use [*Boost.Container]? There are several reasons for that:
[section:release_notes Release Notes]
[section:release_notes_boost_1_71_00 Boost 1.71 Release]
* [@https://github.com/boostorg/container/issues/88 GitHub #88: ['"Implement C++17 MoveAssignable requirements for self-move assignments"]].
* [@https://github.com/boostorg/container/pull/109 GitHub #109: ['"Get rid of integer overflow in copy_move_algo.hpp (-fsanitize=integer)"]].
* [@https://github.com/boostorg/container/pull/110 GitHub #110: ['"Avoid gcc 9 deprecated copy warnings in new_allocator.hpp"]].
* [@https://github.com/boostorg/container/issues/112 GitHub #112: ['"vector::resize() compilation error with msvc-10..12: data is not a member of boost::detail::aligned_storage"]].

View File

@@ -811,7 +811,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
//! <b>Complexity</b>: Linear to the number of elements in x.
deque& operator= (BOOST_COPY_ASSIGN_REF(deque) x)
{
if (&x != this){
if (BOOST_LIKELY(&x != this)){
allocator_type &this_alloc = this->alloc();
const allocator_type &x_alloc = x.alloc();
dtl::bool_<allocator_traits_type::
@@ -839,7 +839,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value
|| allocator_traits_type::is_always_equal::value)
{
BOOST_ASSERT(this != &x);
if (BOOST_LIKELY(this != &x)) {
allocator_type &this_alloc = this->alloc();
allocator_type &x_alloc = x.alloc();
const bool propagate_alloc = allocator_traits_type::
@@ -862,6 +862,7 @@ class deque : protected deque_base<typename real_allocator<T, Allocator>::type,
this->assign( boost::make_move_iterator(x.begin())
, boost::make_move_iterator(x.end()));
}
}
return *this;
}

View File

@@ -788,7 +788,7 @@ class tree
tree& operator=(BOOST_COPY_ASSIGN_REF(tree) x)
{
if (&x != this){
if (BOOST_LIKELY(this != &x)) {
NodeAlloc &this_alloc = this->get_stored_allocator();
const NodeAlloc &x_alloc = x.get_stored_allocator();
dtl::bool_<allocator_traits<NodeAlloc>::
@@ -822,7 +822,7 @@ class tree
allocator_traits_type::is_always_equal::value) &&
boost::container::dtl::is_nothrow_move_assignable<Compare>::value)
{
BOOST_ASSERT(this != &x);
if (BOOST_LIKELY(this != &x)) {
NodeAlloc &this_alloc = this->node_alloc();
NodeAlloc &x_alloc = x.node_alloc();
const bool propagate_alloc = allocator_traits<NodeAlloc>::
@@ -857,6 +857,7 @@ class tree
AllocHolder::destroy_node(p);
}
}
}
return *this;
}

View File

@@ -367,7 +367,7 @@ class list
//! <b>Complexity</b>: Linear to the number of elements in x.
list& operator=(BOOST_COPY_ASSIGN_REF(list) x)
{
if (&x != this){
if (BOOST_LIKELY(this != &x)) {
NodeAlloc &this_alloc = this->node_alloc();
const NodeAlloc &x_alloc = x.node_alloc();
dtl::bool_<allocator_traits_type::
@@ -396,7 +396,7 @@ class list
BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value
|| allocator_traits_type::is_always_equal::value)
{
BOOST_ASSERT(this != &x);
if (BOOST_LIKELY(this != &x)) {
NodeAlloc &this_alloc = this->node_alloc();
NodeAlloc &x_alloc = x.node_alloc();
const bool propagate_alloc = allocator_traits_type::
@@ -417,6 +417,7 @@ class list
this->assign( boost::make_move_iterator(x.begin())
, boost::make_move_iterator(x.end()));
}
}
return *this;
}

View File

@@ -395,7 +395,7 @@ class slist
//! <b>Complexity</b>: Linear to the number of elements in x.
slist& operator= (BOOST_COPY_ASSIGN_REF(slist) x)
{
if (&x != this){
if (BOOST_LIKELY(this != &x)) {
NodeAlloc &this_alloc = this->node_alloc();
const NodeAlloc &x_alloc = x.node_alloc();
dtl::bool_<allocator_traits_type::
@@ -424,7 +424,7 @@ class slist
BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value
|| allocator_traits_type::is_always_equal::value)
{
BOOST_ASSERT(this != &x);
if (BOOST_LIKELY(this != &x)) {
NodeAlloc &this_alloc = this->node_alloc();
NodeAlloc &x_alloc = x.node_alloc();
const bool propagate_alloc = allocator_traits_type::
@@ -445,6 +445,7 @@ class slist
this->assign( boost::make_move_iterator(x.begin())
, boost::make_move_iterator(x.end()));
}
}
return *this;
}

View File

@@ -823,7 +823,7 @@ class stable_vector
stable_vector& operator=(BOOST_COPY_ASSIGN_REF(stable_vector) x)
{
STABLE_VECTOR_CHECK_INVARIANT;
if (&x != this){
if (BOOST_LIKELY(this != &x)) {
node_allocator_type &this_alloc = this->priv_node_alloc();
const node_allocator_type &x_alloc = x.priv_node_alloc();
dtl::bool_<allocator_traits_type::
@@ -855,7 +855,7 @@ class stable_vector
|| allocator_traits_type::is_always_equal::value)
{
//for move constructor, no aliasing (&x != this) is assumed.
BOOST_ASSERT(this != &x);
if (BOOST_LIKELY(this != &x)) {
node_allocator_type &this_alloc = this->priv_node_alloc();
node_allocator_type &x_alloc = x.priv_node_alloc();
const bool propagate_alloc = allocator_traits_type::
@@ -879,6 +879,7 @@ class stable_vector
this->assign( boost::make_move_iterator(x.begin())
, boost::make_move_iterator(x.end()));
}
}
return *this;
}

View File

@@ -865,7 +865,7 @@ class basic_string
//! <b>Complexity</b>: Linear to the elements x contains.
basic_string& operator=(BOOST_COPY_ASSIGN_REF(basic_string) x)
{
if (&x != this){
if (BOOST_LIKELY(this != &x)) {
allocator_type &this_alloc = this->alloc();
const allocator_type &x_alloc = x.alloc();
dtl::bool_<allocator_traits_type::
@@ -896,8 +896,7 @@ class basic_string
BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value
|| allocator_traits_type::is_always_equal::value)
{
//for move constructor, no aliasing (&x != this) is assumed.
BOOST_ASSERT(this != &x);
if (BOOST_LIKELY(this != &x)) {
allocator_type &this_alloc = this->alloc();
allocator_type &x_alloc = x.alloc();
const bool propagate_alloc = allocator_traits_type::
@@ -918,6 +917,7 @@ class basic_string
else{
this->assign( x.begin(), x.end());
}
}
return *this;
}