Fix bug in hint-based overload for node_type insertion where elements were erroneously reallocated

This commit is contained in:
Christian Mazakas
2023-02-19 21:24:43 -08:00
parent d26aeed68f
commit 53580a3070
2 changed files with 22 additions and 6 deletions

View File

@ -422,8 +422,16 @@ namespace boost {
BOOST_ASSERT(get_allocator() == nh.get_allocator());
auto itp = table_.insert(map_types::move(nh.element()));
typename map_types::element_type x;
x.p = std::addressof(nh.element());
auto itp = table_.insert(std::move(x));
if (itp.second) {
nh.reset();
return itp.first;
} else {
return itp.first;
}
}
template <class M>

View File

@ -410,8 +410,16 @@ namespace boost {
BOOST_ASSERT(get_allocator() == nh.get_allocator());
auto itp = table_.insert(set_types::move(nh.element()));
typename set_types::element_type x;
x.p=std::addressof(nh.element());
auto itp = table_.insert(std::move(x));
if (itp.second) {
nh.reset();
return itp.first;
} else {
return itp.first;
}
}
template <class... Args>