mirror of
https://github.com/boostorg/unordered.git
synced 2025-07-30 11:27:15 +02:00
Fix bug in hint-based overload for node_type insertion where elements were erroneously reallocated
This commit is contained in:
@ -422,8 +422,16 @@ namespace boost {
|
|||||||
|
|
||||||
BOOST_ASSERT(get_allocator() == nh.get_allocator());
|
BOOST_ASSERT(get_allocator() == nh.get_allocator());
|
||||||
|
|
||||||
auto itp = table_.insert(map_types::move(nh.element()));
|
typename map_types::element_type x;
|
||||||
return itp.first;
|
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>
|
template <class M>
|
||||||
@ -594,7 +602,7 @@ namespace boost {
|
|||||||
node_type extract(key_type const& key)
|
node_type extract(key_type const& key)
|
||||||
{
|
{
|
||||||
auto pos = find(key);
|
auto pos = find(key);
|
||||||
return pos!=end()?extract(pos):node_type();
|
return pos != end() ? extract(pos) : node_type();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K>
|
template <class K>
|
||||||
@ -605,7 +613,7 @@ namespace boost {
|
|||||||
extract(K const& key)
|
extract(K const& key)
|
||||||
{
|
{
|
||||||
auto pos = find(key);
|
auto pos = find(key);
|
||||||
return pos!=end()?extract(pos):node_type();
|
return pos != end() ? extract(pos) : node_type();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class H2, class P2>
|
template <class H2, class P2>
|
||||||
|
@ -410,8 +410,16 @@ namespace boost {
|
|||||||
|
|
||||||
BOOST_ASSERT(get_allocator() == nh.get_allocator());
|
BOOST_ASSERT(get_allocator() == nh.get_allocator());
|
||||||
|
|
||||||
auto itp = table_.insert(set_types::move(nh.element()));
|
typename set_types::element_type x;
|
||||||
return itp.first;
|
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>
|
template <class... Args>
|
||||||
|
Reference in New Issue
Block a user