mirror of
https://github.com/boostorg/container.git
synced 2025-08-05 15:24:31 +02:00
@@ -1721,11 +1721,11 @@ class deque : protected deque_base<T, Allocator>
|
|||||||
this->members_.m_finish = new_finish;
|
this->members_.m_finish = new_finish;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
pos = this->members_.m_finish - elemsafter;
|
pos = old_finish - elemsafter;
|
||||||
if (elemsafter >= n) {
|
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
|
::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;
|
this->members_.m_finish = new_finish;
|
||||||
boost::move_backward(pos, finish_n, old_finish);
|
boost::move_backward(pos, finish_n, old_finish);
|
||||||
interf.copy_n_and_update(pos, n);
|
interf.copy_n_and_update(pos, n);
|
||||||
@@ -1733,25 +1733,17 @@ class deque : protected deque_base<T, Allocator>
|
|||||||
else {
|
else {
|
||||||
const size_type raw_gap = n - elemsafter;
|
const size_type raw_gap = n - elemsafter;
|
||||||
::boost::container::uninitialized_move_alloc
|
::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{
|
BOOST_TRY{
|
||||||
|
interf.copy_n_and_update(pos, elemsafter);
|
||||||
interf.uninitialized_copy_n_and_update(old_finish, raw_gap);
|
interf.uninitialized_copy_n_and_update(old_finish, raw_gap);
|
||||||
}
|
}
|
||||||
BOOST_CATCH(...){
|
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_RETHROW
|
||||||
}
|
}
|
||||||
BOOST_CATCH_END
|
BOOST_CATCH_END
|
||||||
this->members_.m_finish = new_finish;
|
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);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -207,6 +207,20 @@ bool do_test()
|
|||||||
stddeque->insert(stddeque->end(), aux_vect2, aux_vect2 + 50);
|
stddeque->insert(stddeque->end(), aux_vect2, aux_vect2 + 50);
|
||||||
if(!test::CheckEqualContainers(cntdeque, stddeque)) return false;
|
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){
|
for(int i = 0, j = static_cast<int>(cntdeque->size()); i < j; ++i){
|
||||||
cntdeque->erase(cntdeque->begin());
|
cntdeque->erase(cntdeque->begin());
|
||||||
stddeque->erase(stddeque->begin());
|
stddeque->erase(stddeque->begin());
|
||||||
|
@@ -172,38 +172,38 @@ int vector_test()
|
|||||||
|
|
||||||
IntType aux_vect[50];
|
IntType aux_vect[50];
|
||||||
for(int i = 0; i < 50; ++i){
|
for(int i = 0; i < 50; ++i){
|
||||||
IntType new_int(-2);
|
IntType new_int(-i);
|
||||||
aux_vect[i] = boost::move(new_int);
|
aux_vect[i] = boost::move(new_int);
|
||||||
}
|
}
|
||||||
int aux_vect2[50];
|
int aux_vect2[50];
|
||||||
for(int i = 0; i < 50; ++i){
|
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::size_type old_size = boostvector->size();
|
||||||
typename MyBoostVector::iterator insert_it =
|
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[0])
|
||||||
,boost::make_move_iterator(aux_vect + 50));
|
,boost::make_move_iterator(aux_vect + 50));
|
||||||
if(boostvector->begin() + old_size != insert_it) return 1;
|
if(boostvector->begin() + old_size/2 != insert_it) return 1;
|
||||||
stdvector->insert(stdvector->begin() + old_size, aux_vect2, aux_vect2 + 50);
|
stdvector->insert(stdvector->begin() + old_size/2, aux_vect2, aux_vect2 + 50);
|
||||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||||
|
|
||||||
for(int i = 0; i < 50; ++i){
|
for(int i = 0; i < 50; ++i){
|
||||||
IntType new_int(-3);
|
IntType new_int(-i);
|
||||||
aux_vect[i] = boost::move(new_int);
|
aux_vect[i] = boost::move(new_int);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < 50; ++i){
|
for(int i = 0; i < 50; ++i){
|
||||||
aux_vect2[i] = -3;
|
aux_vect2[i] = -i;
|
||||||
}
|
}
|
||||||
old_size = boostvector->size();
|
old_size = boostvector->size();
|
||||||
//Now try with input iterators instead
|
//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[0]))
|
||||||
,boost::make_move_iterator(make_input_from_forward_iterator(aux_vect + 50))
|
,boost::make_move_iterator(make_input_from_forward_iterator(aux_vect + 50))
|
||||||
);
|
);
|
||||||
if(boostvector->begin() + old_size != insert_it) return 1;
|
if(boostvector->begin() + old_size/2 != insert_it) return 1;
|
||||||
stdvector->insert(stdvector->begin() + old_size, aux_vect2, aux_vect2 + 50);
|
stdvector->insert(stdvector->begin() + old_size/2, aux_vect2, aux_vect2 + 50);
|
||||||
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
if(!test::CheckEqualContainers(boostvector, stdvector)) return 1;
|
||||||
}
|
}
|
||||||
/* //deque has no reserve
|
/* //deque has no reserve
|
||||||
|
Reference in New Issue
Block a user