Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion include/boost/container/hub.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1936,10 +1936,14 @@ class hub
while(first != last) {
int n;
auto pb = retrieve_available_block(n);
if(pb->mask == 0) {
//blocks used are empty from this point on (reserved or newly allocated)
range_insert_adjacent(first, last, construct_, pb);
return;
}
for(; ; ) {
construct_(boost::movelib::to_raw_pointer(pb->data() + n), first++);
++size_;
if(BOOST_UNLIKELY(pb->mask == 0)) blist.link_at_back(pb);
pb->mask |= pb->mask +1;
if(pb->mask == full) {
blist.unlink_available(pb);
Expand All @@ -1951,6 +1955,46 @@ class hub
}
}

template<typename Incrementable, typename Sentinel, typename Construct>
void range_insert_adjacent(
Incrementable& first, Sentinel last, Construct construct_, block_pointer pb)
{
for(;;) {
BOOST_ASSERT(pb->mask == 0);
T* p = boost::movelib::to_raw_pointer(pb->data());
int i = 0;
BOOST_CONTAINER_TRY {
for(;;) {
construct_(p + i, first++);
if(++i == N || first == last) break;
}
}
BOOST_CONTAINER_CATCH(...) {
if(i != 0) {
blist.link_at_back(pb);
size_ += (size_type)i;
pb->mask = (mask_type(1) << i) - 1;
}
BOOST_CONTAINER_RETHROW;
}
BOOST_CONTAINER_CATCH_END

blist.link_at_back(pb);
size_ += (size_type)i;
if(i == N) {
pb->mask = full;
blist.unlink_available(pb);
}
else {
pb->mask = (mask_type(1) << i) - 1;
return;
}
if(first == last) return;
int n;
pb = retrieve_available_block(n);
}
}

template<
typename Incrementable, typename Sentinel,
typename Construct, typename Insert
Expand Down