Add allocator aware move constructors

This commit is contained in:
Christian Mazakas
2023-04-19 15:18:53 -07:00
parent 8bd07e17c3
commit 7812b26d3a
3 changed files with 154 additions and 4 deletions
@@ -192,6 +192,11 @@ namespace boost {
{
}
concurrent_flat_map(concurrent_flat_map&& rhs, allocator_type a)
: table_(std::move(rhs.table_), a)
{
}
/// Capacity
///
+18 -3
View File
@@ -1274,12 +1274,27 @@ public:
}
table_core(table_core&& x,const Allocator& al_):
table_core{0,std::move(x.h()),std::move(x.pred()),al_}
hash_base{empty_init,std::move(x.h())},
pred_base{empty_init,std::move(x.pred())},
allocator_base{empty_init,al_},arrays(new_arrays(0)),
ml{initial_max_load()},size_{0}
{
if(al()==x.al()){
std::swap(arrays,x.arrays);
std::swap(ml,x.ml);
std::swap(size_,x.size_);
// when SizeImpl is an atomic<Integral> type, std::swap() can't be used
// as it's not MoveConstructible so we instead opt for this manual version
{
std::size_t tmp{size_};
size_=static_cast<std::size_t>(x.size_);
x.size_=tmp;
}
{
std::size_t tmp{ml};
ml=static_cast<std::size_t>(x.ml);
x.ml=tmp;
}
}
else{
reserve(x.size());