[SVN r83467]
This commit is contained in:
Ion Gaztañaga
2013-03-16 16:19:08 +00:00
parent 9f25104101
commit f1a4d7f82e
3 changed files with 30 additions and 24 deletions

View File

@@ -1721,11 +1721,11 @@ class deque : protected deque_base<T, Allocator>
this->members_.m_finish = new_finish;
}
else{
pos = this->members_.m_finish - elemsafter;
pos = old_finish - elemsafter;
if (elemsafter >= n) {
iterator finish_n = this->members_.m_finish - difference_type(n);
iterator finish_n = old_finish - difference_type(n);
::boost::container::uninitialized_move_alloc
(this->alloc(), finish_n, this->members_.m_finish, this->members_.m_finish);
(this->alloc(), finish_n, old_finish, old_finish);
this->members_.m_finish = new_finish;
boost::move_backward(pos, finish_n, old_finish);
interf.copy_n_and_update(pos, n);
@@ -1733,25 +1733,17 @@ class deque : protected deque_base<T, Allocator>
else {
const size_type raw_gap = n - elemsafter;
::boost::container::uninitialized_move_alloc
(this->alloc(), pos, old_finish, this->members_.m_finish + raw_gap);
(this->alloc(), pos, old_finish, old_finish + raw_gap);
BOOST_TRY{
interf.copy_n_and_update(pos, elemsafter);
interf.uninitialized_copy_n_and_update(old_finish, raw_gap);
}
BOOST_CATCH(...){
this->priv_destroy_range(this->members_.m_finish, this->members_.m_finish + (old_finish - pos));
this->priv_destroy_range(old_finish, old_finish + elemsafter);
BOOST_RETHROW
}
BOOST_CATCH_END
this->members_.m_finish = new_finish;
interf.copy_n_and_update(pos, elemsafter);
/*
interf.uninitialized_copy_some_and_update(old_finish, elemsafter, false);
this->members_.m_finish += n-elemsafter;
::boost::container::uninitialized_move_alloc
(this->alloc(), pos, old_finish, this->members_.m_finish);
this->members_.m_finish = new_finish;
interf.copy_remaining_to(pos);
*/
}
}
}

View File

@@ -207,6 +207,20 @@ bool do_test()
stddeque->insert(stddeque->end(), aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
for(int i = 0; i < 50; ++i){
IntType move_me (i);
aux_vect[i] = boost::move(move_me);
}
for(int i = 0; i < 50; ++i){
aux_vect2[i] = i;
}
cntdeque->insert(cntdeque->begin()+cntdeque->size()
,boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(aux_vect + 50));
stddeque->insert(stddeque->begin()+stddeque->size(), aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
for(int i = 0, j = static_cast<int>(cntdeque->size()); i < j; ++i){
cntdeque->erase(cntdeque->begin());
stddeque->erase(stddeque->begin());

View File

@@ -172,38 +172,38 @@ int vector_test()
IntType aux_vect[50];
for(int i = 0; i < 50; ++i){
IntType new_int(-2);
IntType new_int(-i);
aux_vect[i] = boost::move(new_int);
}
int aux_vect2[50];
for(int i = 0; i < 50; ++i){
aux_vect2[i] = -2;
aux_vect2[i] = -i;
}
typename MyBoostVector::size_type old_size = boostvector->size();
typename MyBoostVector::iterator insert_it =
boostvector->insert(boostvector->begin() + old_size
boostvector->insert(boostvector->begin() + old_size/2
,boost::make_move_iterator(&aux_vect[0])
,boost::make_move_iterator(aux_vect + 50));
if(boostvector->begin() + old_size != insert_it) return 1;
stdvector->insert(stdvector->begin() + old_size, aux_vect2, aux_vect2 + 50);
if(boostvector->begin() + old_size/2 != insert_it) return 1;
stdvector->insert(stdvector->begin() + old_size/2, aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
for(int i = 0; i < 50; ++i){
IntType new_int(-3);
IntType new_int(-i);
aux_vect[i] = boost::move(new_int);
}
for(int i = 0; i < 50; ++i){
aux_vect2[i] = -3;
aux_vect2[i] = -i;
}
old_size = boostvector->size();
//Now try with input iterators instead
insert_it = boostvector->insert(boostvector->begin() + old_size
insert_it = boostvector->insert(boostvector->begin() + old_size/2
,boost::make_move_iterator(make_input_from_forward_iterator(&aux_vect[0]))
,boost::make_move_iterator(make_input_from_forward_iterator(aux_vect + 50))
);
if(boostvector->begin() + old_size != insert_it) return 1;
stdvector->insert(stdvector->begin() + old_size, aux_vect2, aux_vect2 + 50);
if(boostvector->begin() + old_size/2 != insert_it) return 1;
stdvector->insert(stdvector->begin() + old_size/2, aux_vect2, aux_vect2 + 50);
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
}
/* //deque has no reserve