Fix iterator version of basic_fields::erase

fix #994
This commit is contained in:
Peter Jankuliak
2018-01-22 16:01:51 +01:00
committed by Vinnie Falco
parent ad42096a9d
commit 4fb535ece6
3 changed files with 19 additions and 3 deletions

View File

@ -5,6 +5,7 @@ Version 153:
* Use boost::winapi::GetLastError() consistently
* Update README.md for branches
* Avoid string_view::clear
* Fix iterator version of basic_fields::erase
--------------------------------------------------------------------------------

View File

@ -609,11 +609,11 @@ basic_fields<Allocator>::
erase(const_iterator pos) ->
const_iterator
{
auto next = pos.iter();
auto next = pos;
auto& e = *next++;
set_.erase(e);
list_.erase(e);
delete_element(e);
list_.erase(pos);
delete_element(const_cast<value_type&>(e));
return next;
}

View File

@ -388,6 +388,20 @@ public:
BEAST_EXPECT(size(f) == 2);
}
void testIteratorErase()
{
f_t f;
f.insert("a", "x");
f.insert("b", "y");
f.insert("c", "z");
BEAST_EXPECT(size(f) == 3);
f_t::const_iterator i = std::next(f.begin());
f.erase(i);
BEAST_EXPECT(size(f) == 2);
BEAST_EXPECT(std::next(f.begin(), 0)->name_string() == "a");
BEAST_EXPECT(std::next(f.begin(), 1)->name_string() == "c");
}
void
testContainer()
{
@ -980,6 +994,7 @@ public:
testHeaders();
testRFC2616();
testErase();
testIteratorErase();
testContainer();
testPreparePayload();