moved-from container with unequal allocator will not be modified:

Affects:
- flat_buffer
- multi_buffer
- http::fields

fixes #1832
closes #1834
This commit is contained in:
Richard Hodges
2020-02-04 10:26:41 +01:00
parent 6d10adf936
commit 7701bf8738
6 changed files with 9 additions and 18 deletions

View File

@@ -1,5 +1,6 @@
Version XXX: Version XXX:
* moved-from dynamic buffers do not clear if different allocator
* fix erase field * fix erase field
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@@ -124,8 +124,6 @@ basic_flat_buffer(
end_ = nullptr; end_ = nullptr;
max_ = other.max_; max_ = other.max_;
copy_from(other); copy_from(other);
other.clear();
other.shrink_to_fit();
return; return;
} }
@@ -436,8 +434,6 @@ move_assign(basic_flat_buffer& other, std::false_type)
if(this->get() != other.get()) if(this->get() != other.get())
{ {
copy_from(other); copy_from(other);
other.clear();
other.shrink_to_fit();
} }
else else
{ {

View File

@@ -502,8 +502,6 @@ basic_multi_buffer(
{ {
out_ = list_.end(); out_ = list_.end();
copy_from(other); copy_from(other);
other.clear();
other.shrink_to_fit();
return; return;
} }
@@ -1060,8 +1058,6 @@ move_assign(basic_multi_buffer& other, std::false_type)
if(this->get() != other.get()) if(this->get() != other.get())
{ {
copy_from(other); copy_from(other);
other.clear();
other.shrink_to_fit();
} }
else else
{ {

View File

@@ -382,7 +382,6 @@ basic_fields(basic_fields&& other, Allocator const& alloc)
if(this->get() != other.get()) if(this->get() != other.get())
{ {
copy_all(other); copy_all(other);
other.clear_all();
} }
else else
{ {
@@ -1139,7 +1138,6 @@ move_assign(basic_fields& other, std::false_type)
if(this->get() != other.get()) if(this->get() != other.get())
{ {
copy_all(other); copy_all(other);
other.clear_all();
} }
else else
{ {

View File

@@ -103,8 +103,8 @@ public:
ostream(b1) << "Hello"; ostream(b1) << "Hello";
a_neq_t a; a_neq_t a;
basic_flat_buffer<a_neq_t> b2{std::move(b1), a}; basic_flat_buffer<a_neq_t> b2{std::move(b1), a};
BEAST_EXPECT(b1.size() == 0); BEAST_EXPECT(b1.size() != 0);
BEAST_EXPECT(b1.capacity() == 0); BEAST_EXPECT(b1.capacity() != 0);
BEAST_EXPECT(buffers_to_string(b2.data()) == "Hello"); BEAST_EXPECT(buffers_to_string(b2.data()) == "Hello");
BEAST_EXPECT(b1.max_size() == b2.max_size()); BEAST_EXPECT(b1.max_size() == b2.max_size());
} }
@@ -186,8 +186,8 @@ public:
basic_flat_buffer<na_t> b2; basic_flat_buffer<na_t> b2;
b2 = std::move(b1); b2 = std::move(b1);
BEAST_EXPECT(b1.get_allocator() != b2.get_allocator()); BEAST_EXPECT(b1.get_allocator() != b2.get_allocator());
BEAST_EXPECT(b1.size() == 0); BEAST_EXPECT(b1.size() != 0);
BEAST_EXPECT(b1.capacity() == 0); BEAST_EXPECT(b1.capacity() != 0);
BEAST_EXPECT(buffers_to_string(b2.data()) == "Hello"); BEAST_EXPECT(buffers_to_string(b2.data()) == "Hello");
} }
{ {

View File

@@ -237,8 +237,8 @@ public:
ostream(b1) << "Hello"; ostream(b1) << "Hello";
unequal_t a; unequal_t a;
basic_multi_buffer<unequal_t> b2{std::move(b1), a}; basic_multi_buffer<unequal_t> b2{std::move(b1), a};
BEAST_EXPECT(b1.size() == 0); BEAST_EXPECT(b1.size() != 0);
BEAST_EXPECT(b1.capacity() == 0); BEAST_EXPECT(b1.capacity() != 0);
BEAST_EXPECT(buffers_to_string(b2.data()) == "Hello"); BEAST_EXPECT(buffers_to_string(b2.data()) == "Hello");
BEAST_EXPECT(b1.max_size() == b2.max_size()); BEAST_EXPECT(b1.max_size() == b2.max_size());
} }
@@ -300,8 +300,8 @@ public:
basic_multi_buffer<na_t> b2; basic_multi_buffer<na_t> b2;
b2 = std::move(b1); b2 = std::move(b1);
BEAST_EXPECT(b1.get_allocator() != b2.get_allocator()); BEAST_EXPECT(b1.get_allocator() != b2.get_allocator());
BEAST_EXPECT(b1.size() == 0); BEAST_EXPECT(b1.size() != 0);
BEAST_EXPECT(b1.capacity() == 0); BEAST_EXPECT(b1.capacity() != 0);
BEAST_EXPECT(buffers_to_string(b2.data()) == "Hello"); BEAST_EXPECT(buffers_to_string(b2.data()) == "Hello");
} }
{ {