This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On Thu, 2004-03-25 at 11:10, B. Kosnik wrote: > Hey Dhruv. Here's a patch for the testsuite that points out the issue > you noticed with using a virtual clear member function in base class for > certain STL sequences. > > Your patches for this problem are difficult to follow. Not the patch > itself, or the reasoning, but the posts and repost and followups of just > certain file diffs. > The fact that I've taken so long to review this stuff certainly hasn't > helped: for that, I apologize. That's ok :-) > Is there any chance you could give me a single patch for vector, deque, > and list that fixes these testsuite failures? It's attached with this message. Also, this includes the patch for stl_tree and cpp_type_traits. -- -Dhruv Matani. http://www.geocities.com/dhruvbird/ Proud to be a Vegetarian. http://www.vegetarianstarterkit.com/ http://www.vegkids.com/vegkids/index.html
Attachment:
changelog_unified
Description: Text document
diff -Nrcp -x '*cvs*' ./include/bits/cpp_type_traits.h /home/dhruv/projects/cvs_libstdc++-v3/include/bits/cpp_type_traits.h
*** ./include/bits/cpp_type_traits.h 2004-03-25 15:27:39.000000000 +0530
--- /home/dhruv/projects/cvs_libstdc++-v3/include/bits/cpp_type_traits.h 2004-02-08 10:16:40.000000000 +0530
*************** namespace std
*** 317,343 ****
//
// For the immediate use, the following is a good approximation
//
-
- // NB: g++ can not compile these if declared within the class
- // __is_pod itself.
- namespace __gnu_internal
- {
- typedef char __one;
- typedef char __two[2];
-
- template <typename _Tp>
- __one __test_type (int _Tp::*);
- template <typename _Tp>
- __two& __test_type (...);
- }
-
-
template<typename _Tp>
struct __is_pod
{
enum
{
! _M_type = (sizeof(__gnu_internal::__test_type<_Tp>(0)) != sizeof(__gnu_internal::__one))
};
};
--- 317,328 ----
//
// For the immediate use, the following is a good approximation
//
template<typename _Tp>
struct __is_pod
{
enum
{
! _M_type = __is_fundamental<_Tp>::_M_type
};
};
diff -Nrcp -x '*cvs*' ./include/bits/deque.tcc /home/dhruv/projects/cvs_libstdc++-v3/include/bits/deque.tcc
*** ./include/bits/deque.tcc 2004-03-25 15:13:48.000000000 +0530
--- /home/dhruv/projects/cvs_libstdc++-v3/include/bits/deque.tcc 2004-02-08 10:16:40.000000000 +0530
*************** namespace __gnu_norm
*** 72,84 ****
if (&__x != this)
{
if (__len >= __x.size())
! erase(std::copy(__x.begin(), __x.end(), this->_M_impl._M_start),
! this->_M_impl._M_finish);
else
{
const_iterator __mid = __x.begin() + difference_type(__len);
! std::copy(__x.begin(), __mid, this->_M_impl._M_start);
! insert(this->_M_impl._M_finish, __mid, __x.end());
}
}
return *this;
--- 72,84 ----
if (&__x != this)
{
if (__len >= __x.size())
! erase(std::copy(__x.begin(), __x.end(), this->_M_start),
! this->_M_finish);
else
{
const_iterator __mid = __x.begin() + difference_type(__len);
! std::copy(__x.begin(), __mid, this->_M_start);
! insert(this->_M_finish, __mid, __x.end());
}
}
return *this;
*************** namespace __gnu_norm
*** 89,103 ****
deque<_Tp,_Alloc>::
insert(iterator position, const value_type& __x)
{
! if (position._M_cur == this->_M_impl._M_start._M_cur)
{
push_front(__x);
! return this->_M_impl._M_start;
}
! else if (position._M_cur == this->_M_impl._M_finish._M_cur)
{
push_back(__x);
! iterator __tmp = this->_M_impl._M_finish;
--__tmp;
return __tmp;
}
--- 89,103 ----
deque<_Tp,_Alloc>::
insert(iterator position, const value_type& __x)
{
! if (position._M_cur == this->_M_start._M_cur)
{
push_front(__x);
! return this->_M_start;
}
! else if (position._M_cur == this->_M_finish._M_cur)
{
push_back(__x);
! iterator __tmp = this->_M_finish;
--__tmp;
return __tmp;
}
*************** namespace __gnu_norm
*** 112,129 ****
{
iterator __next = __position;
++__next;
! size_type __index = __position - this->_M_impl._M_start;
if (__index < (size() >> 1))
{
! std::copy_backward(this->_M_impl._M_start, __position, __next);
pop_front();
}
else
{
! std::copy(__next, this->_M_impl._M_finish, __position);
pop_back();
}
! return this->_M_impl._M_start + __index;
}
template <typename _Tp, typename _Alloc>
--- 112,129 ----
{
iterator __next = __position;
++__next;
! size_type __index = __position - this->_M_start;
if (__index < (size() >> 1))
{
! std::copy_backward(this->_M_start, __position, __next);
pop_front();
}
else
{
! std::copy(__next, this->_M_finish, __position);
pop_back();
}
! return this->_M_start + __index;
}
template <typename _Tp, typename _Alloc>
*************** namespace __gnu_norm
*** 131,163 ****
deque<_Tp,_Alloc>::
erase(iterator __first, iterator __last)
{
! if (__first == this->_M_impl._M_start && __last == this->_M_impl._M_finish)
{
clear();
! return this->_M_impl._M_finish;
}
else
{
const difference_type __n = __last - __first;
! const difference_type __elems_before = __first - this->_M_impl._M_start;
if (static_cast<size_type>(__elems_before) < (size() - __n) / 2)
{
! std::copy_backward(this->_M_impl._M_start, __first, __last);
! iterator __new_start = this->_M_impl._M_start + __n;
! std::_Destroy(this->_M_impl._M_start, __new_start);
! _M_destroy_nodes(this->_M_impl._M_start._M_node, __new_start._M_node);
! this->_M_impl._M_start = __new_start;
}
else
{
! std::copy(__last, this->_M_impl._M_finish, __first);
! iterator __new_finish = this->_M_impl._M_finish - __n;
! std::_Destroy(__new_finish, this->_M_impl._M_finish);
_M_destroy_nodes(__new_finish._M_node + 1,
! this->_M_impl._M_finish._M_node + 1);
! this->_M_impl._M_finish = __new_finish;
}
! return this->_M_impl._M_start + __elems_before;
}
}
--- 131,163 ----
deque<_Tp,_Alloc>::
erase(iterator __first, iterator __last)
{
! if (__first == this->_M_start && __last == this->_M_finish)
{
clear();
! return this->_M_finish;
}
else
{
const difference_type __n = __last - __first;
! const difference_type __elems_before = __first - this->_M_start;
if (static_cast<size_type>(__elems_before) < (size() - __n) / 2)
{
! std::copy_backward(this->_M_start, __first, __last);
! iterator __new_start = this->_M_start + __n;
! std::_Destroy(this->_M_start, __new_start);
! _M_destroy_nodes(this->_M_start._M_node, __new_start._M_node);
! this->_M_start = __new_start;
}
else
{
! std::copy(__last, this->_M_finish, __first);
! iterator __new_finish = this->_M_finish - __n;
! std::_Destroy(__new_finish, this->_M_finish);
_M_destroy_nodes(__new_finish._M_node + 1,
! this->_M_finish._M_node + 1);
! this->_M_finish = __new_finish;
}
! return this->_M_start + __elems_before;
}
}
*************** namespace __gnu_norm
*** 166,189 ****
deque<_Tp,_Alloc>::
clear()
{
! for (_Map_pointer __node = this->_M_impl._M_start._M_node + 1;
! __node < this->_M_impl._M_finish._M_node;
++__node)
{
std::_Destroy(*__node, *__node + _S_buffer_size());
_M_deallocate_node(*__node);
}
! if (this->_M_impl._M_start._M_node != this->_M_impl._M_finish._M_node)
{
! std::_Destroy(this->_M_impl._M_start._M_cur, this->_M_impl._M_start._M_last);
! std::_Destroy(this->_M_impl._M_finish._M_first, this->_M_impl._M_finish._M_cur);
! _M_deallocate_node(this->_M_impl._M_finish._M_first);
}
else
! std::_Destroy(this->_M_impl._M_start._M_cur, this->_M_impl._M_finish._M_cur);
! this->_M_impl._M_finish = this->_M_impl._M_start;
}
template <typename _Tp, class _Alloc>
--- 166,189 ----
deque<_Tp,_Alloc>::
clear()
{
! for (_Map_pointer __node = this->_M_start._M_node + 1;
! __node < this->_M_finish._M_node;
++__node)
{
std::_Destroy(*__node, *__node + _S_buffer_size());
_M_deallocate_node(*__node);
}
! if (this->_M_start._M_node != this->_M_finish._M_node)
{
! std::_Destroy(this->_M_start._M_cur, this->_M_start._M_last);
! std::_Destroy(this->_M_finish._M_first, this->_M_finish._M_cur);
! _M_deallocate_node(this->_M_finish._M_first);
}
else
! std::_Destroy(this->_M_start._M_cur, this->_M_finish._M_cur);
! this->_M_finish = this->_M_start;
}
template <typename _Tp, class _Alloc>
*************** namespace __gnu_norm
*** 207,237 ****
deque<_Tp,_Alloc>::
_M_fill_insert(iterator __pos, size_type __n, const value_type& __x)
{
! if (__pos._M_cur == this->_M_impl._M_start._M_cur)
{
iterator __new_start = _M_reserve_elements_at_front(__n);
try
{
! std::uninitialized_fill(__new_start, this->_M_impl._M_start, __x);
! this->_M_impl._M_start = __new_start;
}
catch(...)
{
! _M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node);
__throw_exception_again;
}
}
! else if (__pos._M_cur == this->_M_impl._M_finish._M_cur)
{
iterator __new_finish = _M_reserve_elements_at_back(__n);
try
{
! std::uninitialized_fill(this->_M_impl._M_finish, __new_finish, __x);
! this->_M_impl._M_finish = __new_finish;
}
catch(...)
{
! _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
__new_finish._M_node + 1);
__throw_exception_again;
}
--- 207,237 ----
deque<_Tp,_Alloc>::
_M_fill_insert(iterator __pos, size_type __n, const value_type& __x)
{
! if (__pos._M_cur == this->_M_start._M_cur)
{
iterator __new_start = _M_reserve_elements_at_front(__n);
try
{
! std::uninitialized_fill(__new_start, this->_M_start, __x);
! this->_M_start = __new_start;
}
catch(...)
{
! _M_destroy_nodes(__new_start._M_node, this->_M_start._M_node);
__throw_exception_again;
}
}
! else if (__pos._M_cur == this->_M_finish._M_cur)
{
iterator __new_finish = _M_reserve_elements_at_back(__n);
try
{
! std::uninitialized_fill(this->_M_finish, __new_finish, __x);
! this->_M_finish = __new_finish;
}
catch(...)
{
! _M_destroy_nodes(this->_M_finish._M_node + 1,
__new_finish._M_node + 1);
__throw_exception_again;
}
*************** namespace __gnu_norm
*** 248,264 ****
_Map_pointer __cur;
try
{
! for (__cur = this->_M_impl._M_start._M_node;
! __cur < this->_M_impl._M_finish._M_node;
++__cur)
std::uninitialized_fill(*__cur, *__cur + _S_buffer_size(), __value);
! std::uninitialized_fill(this->_M_impl._M_finish._M_first,
! this->_M_impl._M_finish._M_cur,
__value);
}
catch(...)
{
! std::_Destroy(this->_M_impl._M_start, iterator(*__cur, __cur));
__throw_exception_again;
}
}
--- 248,264 ----
_Map_pointer __cur;
try
{
! for (__cur = this->_M_start._M_node;
! __cur < this->_M_finish._M_node;
++__cur)
std::uninitialized_fill(*__cur, *__cur + _S_buffer_size(), __value);
! std::uninitialized_fill(this->_M_finish._M_first,
! this->_M_finish._M_cur,
__value);
}
catch(...)
{
! std::_Destroy(this->_M_start, iterator(*__cur, __cur));
__throw_exception_again;
}
}
*************** namespace __gnu_norm
*** 296,303 ****
_Map_pointer __cur_node;
try
{
! for (__cur_node = this->_M_impl._M_start._M_node;
! __cur_node < this->_M_impl._M_finish._M_node;
++__cur_node)
{
_ForwardIterator __mid = __first;
--- 296,303 ----
_Map_pointer __cur_node;
try
{
! for (__cur_node = this->_M_start._M_node;
! __cur_node < this->_M_finish._M_node;
++__cur_node)
{
_ForwardIterator __mid = __first;
*************** namespace __gnu_norm
*** 305,320 ****
std::uninitialized_copy(__first, __mid, *__cur_node);
__first = __mid;
}
! std::uninitialized_copy(__first, __last, this->_M_impl._M_finish._M_first);
}
catch(...)
{
! std::_Destroy(this->_M_impl._M_start, iterator(*__cur_node, __cur_node));
__throw_exception_again;
}
}
! // Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_last - 1.
template <typename _Tp, typename _Alloc>
void
deque<_Tp,_Alloc>::
--- 305,320 ----
std::uninitialized_copy(__first, __mid, *__cur_node);
__first = __mid;
}
! std::uninitialized_copy(__first, __last, this->_M_finish._M_first);
}
catch(...)
{
! std::_Destroy(this->_M_start, iterator(*__cur_node, __cur_node));
__throw_exception_again;
}
}
! // Called only if _M_finish._M_cur == _M_finish._M_last - 1.
template <typename _Tp, typename _Alloc>
void
deque<_Tp,_Alloc>::
*************** namespace __gnu_norm
*** 322,342 ****
{
value_type __t_copy = __t;
_M_reserve_map_at_back();
! *(this->_M_impl._M_finish._M_node + 1) = this->_M_allocate_node();
try
{
! std::_Construct(this->_M_impl._M_finish._M_cur, __t_copy);
! this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node + 1);
! this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_first;
}
catch(...)
{
! _M_deallocate_node(*(this->_M_impl._M_finish._M_node + 1));
__throw_exception_again;
}
}
! // Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_first.
template <typename _Tp, typename _Alloc>
void
deque<_Tp,_Alloc>::
--- 322,342 ----
{
value_type __t_copy = __t;
_M_reserve_map_at_back();
! *(this->_M_finish._M_node + 1) = this->_M_allocate_node();
try
{
! std::_Construct(this->_M_finish._M_cur, __t_copy);
! this->_M_finish._M_set_node(this->_M_finish._M_node + 1);
! this->_M_finish._M_cur = this->_M_finish._M_first;
}
catch(...)
{
! _M_deallocate_node(*(this->_M_finish._M_node + 1));
__throw_exception_again;
}
}
! // Called only if _M_start._M_cur == _M_start._M_first.
template <typename _Tp, typename _Alloc>
void
deque<_Tp,_Alloc>::
*************** namespace __gnu_norm
*** 344,387 ****
{
value_type __t_copy = __t;
_M_reserve_map_at_front();
! *(this->_M_impl._M_start._M_node - 1) = this->_M_allocate_node();
try
{
! this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node - 1);
! this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_last - 1;
! std::_Construct(this->_M_impl._M_start._M_cur, __t_copy);
}
catch(...)
{
! ++this->_M_impl._M_start;
! _M_deallocate_node(*(this->_M_impl._M_start._M_node - 1));
__throw_exception_again;
}
}
! // Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_first.
template <typename _Tp, typename _Alloc>
void deque<_Tp,_Alloc>::
_M_pop_back_aux()
{
! _M_deallocate_node(this->_M_impl._M_finish._M_first);
! this->_M_impl._M_finish._M_set_node(this->_M_impl._M_finish._M_node - 1);
! this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_last - 1;
! std::_Destroy(this->_M_impl._M_finish._M_cur);
}
! // Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_last - 1. Note that
// if the deque has at least one element (a precondition for this member
! // function), and if _M_impl._M_start._M_cur == _M_impl._M_start._M_last, then the deque
// must have at least two nodes.
template <typename _Tp, typename _Alloc>
void deque<_Tp,_Alloc>::
_M_pop_front_aux()
{
! std::_Destroy(this->_M_impl._M_start._M_cur);
! _M_deallocate_node(this->_M_impl._M_start._M_first);
! this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node + 1);
! this->_M_impl._M_start._M_cur = this->_M_impl._M_start._M_first;
}
template <typename _Tp, typename _Alloc>
--- 344,387 ----
{
value_type __t_copy = __t;
_M_reserve_map_at_front();
! *(this->_M_start._M_node - 1) = this->_M_allocate_node();
try
{
! this->_M_start._M_set_node(this->_M_start._M_node - 1);
! this->_M_start._M_cur = this->_M_start._M_last - 1;
! std::_Construct(this->_M_start._M_cur, __t_copy);
}
catch(...)
{
! ++this->_M_start;
! _M_deallocate_node(*(this->_M_start._M_node - 1));
__throw_exception_again;
}
}
! // Called only if _M_finish._M_cur == _M_finish._M_first.
template <typename _Tp, typename _Alloc>
void deque<_Tp,_Alloc>::
_M_pop_back_aux()
{
! _M_deallocate_node(this->_M_finish._M_first);
! this->_M_finish._M_set_node(this->_M_finish._M_node - 1);
! this->_M_finish._M_cur = this->_M_finish._M_last - 1;
! std::_Destroy(this->_M_finish._M_cur);
}
! // Called only if _M_start._M_cur == _M_start._M_last - 1. Note that
// if the deque has at least one element (a precondition for this member
! // function), and if _M_start._M_cur == _M_start._M_last, then the deque
// must have at least two nodes.
template <typename _Tp, typename _Alloc>
void deque<_Tp,_Alloc>::
_M_pop_front_aux()
{
! std::_Destroy(this->_M_start._M_cur);
! _M_deallocate_node(this->_M_start._M_first);
! this->_M_start._M_set_node(this->_M_start._M_node + 1);
! this->_M_start._M_cur = this->_M_start._M_first;
}
template <typename _Tp, typename _Alloc>
*************** namespace __gnu_norm
*** 402,432 ****
forward_iterator_tag)
{
size_type __n = std::distance(__first, __last);
! if (__pos._M_cur == this->_M_impl._M_start._M_cur)
{
iterator __new_start = _M_reserve_elements_at_front(__n);
try
{
std::uninitialized_copy(__first, __last, __new_start);
! this->_M_impl._M_start = __new_start;
}
catch(...)
{
! _M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node);
__throw_exception_again;
}
}
! else if (__pos._M_cur == this->_M_impl._M_finish._M_cur)
{
iterator __new_finish = _M_reserve_elements_at_back(__n);
try
{
! std::uninitialized_copy(__first, __last, this->_M_impl._M_finish);
! this->_M_impl._M_finish = __new_finish;
}
catch(...)
{
! _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
__new_finish._M_node + 1);
__throw_exception_again;
}
--- 402,432 ----
forward_iterator_tag)
{
size_type __n = std::distance(__first, __last);
! if (__pos._M_cur == this->_M_start._M_cur)
{
iterator __new_start = _M_reserve_elements_at_front(__n);
try
{
std::uninitialized_copy(__first, __last, __new_start);
! this->_M_start = __new_start;
}
catch(...)
{
! _M_destroy_nodes(__new_start._M_node, this->_M_start._M_node);
__throw_exception_again;
}
}
! else if (__pos._M_cur == this->_M_finish._M_cur)
{
iterator __new_finish = _M_reserve_elements_at_back(__n);
try
{
! std::uninitialized_copy(__first, __last, this->_M_finish);
! this->_M_finish = __new_finish;
}
catch(...)
{
! _M_destroy_nodes(this->_M_finish._M_node + 1,
__new_finish._M_node + 1);
__throw_exception_again;
}
*************** namespace __gnu_norm
*** 440,455 ****
deque<_Tp,_Alloc>::
_M_insert_aux(iterator __pos, const value_type& __x)
{
! difference_type __index = __pos - this->_M_impl._M_start;
value_type __x_copy = __x; // XXX copy
if (static_cast<size_type>(__index) < size() / 2)
{
push_front(front());
! iterator __front1 = this->_M_impl._M_start;
++__front1;
iterator __front2 = __front1;
++__front2;
! __pos = this->_M_impl._M_start + __index;
iterator __pos1 = __pos;
++__pos1;
std::copy(__front2, __pos1, __front1);
--- 440,455 ----
deque<_Tp,_Alloc>::
_M_insert_aux(iterator __pos, const value_type& __x)
{
! difference_type __index = __pos - this->_M_start;
value_type __x_copy = __x; // XXX copy
if (static_cast<size_type>(__index) < size() / 2)
{
push_front(front());
! iterator __front1 = this->_M_start;
++__front1;
iterator __front2 = __front1;
++__front2;
! __pos = this->_M_start + __index;
iterator __pos1 = __pos;
++__pos1;
std::copy(__front2, __pos1, __front1);
*************** namespace __gnu_norm
*** 457,467 ****
else
{
push_back(back());
! iterator __back1 = this->_M_impl._M_finish;
--__back1;
iterator __back2 = __back1;
--__back2;
! __pos = this->_M_impl._M_start + __index;
std::copy_backward(__pos, __back2, __back1);
}
*__pos = __x_copy;
--- 457,467 ----
else
{
push_back(back());
! iterator __back1 = this->_M_finish;
--__back1;
iterator __back2 = __back1;
--__back2;
! __pos = this->_M_start + __index;
std::copy_backward(__pos, __back2, __back1);
}
*__pos = __x_copy;
*************** namespace __gnu_norm
*** 473,543 ****
deque<_Tp,_Alloc>::
_M_insert_aux(iterator __pos, size_type __n, const value_type& __x)
{
! const difference_type __elems_before = __pos - this->_M_impl._M_start;
size_type __length = this->size();
value_type __x_copy = __x;
if (__elems_before < difference_type(__length / 2))
{
iterator __new_start = _M_reserve_elements_at_front(__n);
! iterator __old_start = this->_M_impl._M_start;
! __pos = this->_M_impl._M_start + __elems_before;
try
{
if (__elems_before >= difference_type(__n))
{
! iterator __start_n = this->_M_impl._M_start + difference_type(__n);
! std::uninitialized_copy(this->_M_impl._M_start, __start_n,
__new_start);
! this->_M_impl._M_start = __new_start;
std::copy(__start_n, __pos, __old_start);
fill(__pos - difference_type(__n), __pos, __x_copy);
}
else
{
! std::__uninitialized_copy_fill(this->_M_impl._M_start, __pos,
__new_start,
! this->_M_impl._M_start, __x_copy);
! this->_M_impl._M_start = __new_start;
std::fill(__old_start, __pos, __x_copy);
}
}
catch(...)
{
! _M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node);
__throw_exception_again;
}
}
else
{
iterator __new_finish = _M_reserve_elements_at_back(__n);
! iterator __old_finish = this->_M_impl._M_finish;
const difference_type __elems_after =
difference_type(__length) - __elems_before;
! __pos = this->_M_impl._M_finish - __elems_after;
try
{
if (__elems_after > difference_type(__n))
{
! iterator __finish_n = this->_M_impl._M_finish - difference_type(__n);
! std::uninitialized_copy(__finish_n, this->_M_impl._M_finish,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish = __new_finish;
std::copy_backward(__pos, __finish_n, __old_finish);
std::fill(__pos, __pos + difference_type(__n), __x_copy);
}
else
{
! std::__uninitialized_fill_copy(this->_M_impl._M_finish,
__pos + difference_type(__n),
__x_copy, __pos,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish = __new_finish;
std::fill(__pos, __old_finish, __x_copy);
}
}
catch(...)
{
! _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
__new_finish._M_node + 1);
__throw_exception_again;
}
--- 473,543 ----
deque<_Tp,_Alloc>::
_M_insert_aux(iterator __pos, size_type __n, const value_type& __x)
{
! const difference_type __elems_before = __pos - this->_M_start;
size_type __length = this->size();
value_type __x_copy = __x;
if (__elems_before < difference_type(__length / 2))
{
iterator __new_start = _M_reserve_elements_at_front(__n);
! iterator __old_start = this->_M_start;
! __pos = this->_M_start + __elems_before;
try
{
if (__elems_before >= difference_type(__n))
{
! iterator __start_n = this->_M_start + difference_type(__n);
! std::uninitialized_copy(this->_M_start, __start_n,
__new_start);
! this->_M_start = __new_start;
std::copy(__start_n, __pos, __old_start);
fill(__pos - difference_type(__n), __pos, __x_copy);
}
else
{
! std::__uninitialized_copy_fill(this->_M_start, __pos,
__new_start,
! this->_M_start, __x_copy);
! this->_M_start = __new_start;
std::fill(__old_start, __pos, __x_copy);
}
}
catch(...)
{
! _M_destroy_nodes(__new_start._M_node, this->_M_start._M_node);
__throw_exception_again;
}
}
else
{
iterator __new_finish = _M_reserve_elements_at_back(__n);
! iterator __old_finish = this->_M_finish;
const difference_type __elems_after =
difference_type(__length) - __elems_before;
! __pos = this->_M_finish - __elems_after;
try
{
if (__elems_after > difference_type(__n))
{
! iterator __finish_n = this->_M_finish - difference_type(__n);
! std::uninitialized_copy(__finish_n, this->_M_finish,
! this->_M_finish);
! this->_M_finish = __new_finish;
std::copy_backward(__pos, __finish_n, __old_finish);
std::fill(__pos, __pos + difference_type(__n), __x_copy);
}
else
{
! std::__uninitialized_fill_copy(this->_M_finish,
__pos + difference_type(__n),
__x_copy, __pos,
! this->_M_finish);
! this->_M_finish = __new_finish;
std::fill(__pos, __old_finish, __x_copy);
}
}
catch(...)
{
! _M_destroy_nodes(this->_M_finish._M_node + 1,
__new_finish._M_node + 1);
__throw_exception_again;
}
*************** namespace __gnu_norm
*** 552,572 ****
_ForwardIterator __first, _ForwardIterator __last,
size_type __n)
{
! const difference_type __elemsbefore = __pos - this->_M_impl._M_start;
size_type __length = size();
if (static_cast<size_type>(__elemsbefore) < __length / 2)
{
iterator __new_start = _M_reserve_elements_at_front(__n);
! iterator __old_start = this->_M_impl._M_start;
! __pos = this->_M_impl._M_start + __elemsbefore;
try
{
if (__elemsbefore >= difference_type(__n))
{
! iterator __start_n = this->_M_impl._M_start + difference_type(__n);
! std::uninitialized_copy(this->_M_impl._M_start, __start_n,
__new_start);
! this->_M_impl._M_start = __new_start;
std::copy(__start_n, __pos, __old_start);
std::copy(__first, __last, __pos - difference_type(__n));
}
--- 552,572 ----
_ForwardIterator __first, _ForwardIterator __last,
size_type __n)
{
! const difference_type __elemsbefore = __pos - this->_M_start;
size_type __length = size();
if (static_cast<size_type>(__elemsbefore) < __length / 2)
{
iterator __new_start = _M_reserve_elements_at_front(__n);
! iterator __old_start = this->_M_start;
! __pos = this->_M_start + __elemsbefore;
try
{
if (__elemsbefore >= difference_type(__n))
{
! iterator __start_n = this->_M_start + difference_type(__n);
! std::uninitialized_copy(this->_M_start, __start_n,
__new_start);
! this->_M_start = __new_start;
std::copy(__start_n, __pos, __old_start);
std::copy(__first, __last, __pos - difference_type(__n));
}
*************** namespace __gnu_norm
*** 574,607 ****
{
_ForwardIterator __mid = __first;
std::advance(__mid, difference_type(__n) - __elemsbefore);
! std::__uninitialized_copy_copy(this->_M_impl._M_start, __pos,
__first, __mid, __new_start);
! this->_M_impl._M_start = __new_start;
std::copy(__mid, __last, __old_start);
}
}
catch(...)
{
! _M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node);
__throw_exception_again;
}
}
else
{
iterator __new_finish = _M_reserve_elements_at_back(__n);
! iterator __old_finish = this->_M_impl._M_finish;
const difference_type __elemsafter =
difference_type(__length) - __elemsbefore;
! __pos = this->_M_impl._M_finish - __elemsafter;
try
{
if (__elemsafter > difference_type(__n))
{
! iterator __finish_n = this->_M_impl._M_finish - difference_type(__n);
std::uninitialized_copy(__finish_n,
! this->_M_impl._M_finish,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish = __new_finish;
std::copy_backward(__pos, __finish_n, __old_finish);
std::copy(__first, __last, __pos);
}
--- 574,607 ----
{
_ForwardIterator __mid = __first;
std::advance(__mid, difference_type(__n) - __elemsbefore);
! std::__uninitialized_copy_copy(this->_M_start, __pos,
__first, __mid, __new_start);
! this->_M_start = __new_start;
std::copy(__mid, __last, __old_start);
}
}
catch(...)
{
! _M_destroy_nodes(__new_start._M_node, this->_M_start._M_node);
__throw_exception_again;
}
}
else
{
iterator __new_finish = _M_reserve_elements_at_back(__n);
! iterator __old_finish = this->_M_finish;
const difference_type __elemsafter =
difference_type(__length) - __elemsbefore;
! __pos = this->_M_finish - __elemsafter;
try
{
if (__elemsafter > difference_type(__n))
{
! iterator __finish_n = this->_M_finish - difference_type(__n);
std::uninitialized_copy(__finish_n,
! this->_M_finish,
! this->_M_finish);
! this->_M_finish = __new_finish;
std::copy_backward(__pos, __finish_n, __old_finish);
std::copy(__first, __last, __pos);
}
*************** namespace __gnu_norm
*** 610,624 ****
_ForwardIterator __mid = __first;
std::advance(__mid, __elemsafter);
std::__uninitialized_copy_copy(__mid, __last, __pos,
! this->_M_impl._M_finish,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish = __new_finish;
std::copy(__first, __mid, __pos);
}
}
catch(...)
{
! _M_destroy_nodes(this->_M_impl._M_finish._M_node + 1,
__new_finish._M_node + 1);
__throw_exception_again;
}
--- 610,624 ----
_ForwardIterator __mid = __first;
std::advance(__mid, __elemsafter);
std::__uninitialized_copy_copy(__mid, __last, __pos,
! this->_M_finish,
! this->_M_finish);
! this->_M_finish = __new_finish;
std::copy(__first, __mid, __pos);
}
}
catch(...)
{
! _M_destroy_nodes(this->_M_finish._M_node + 1,
__new_finish._M_node + 1);
__throw_exception_again;
}
*************** namespace __gnu_norm
*** 637,648 ****
try
{
for (__i = 1; __i <= __new_nodes; ++__i)
! *(this->_M_impl._M_start._M_node - __i) = this->_M_allocate_node();
}
catch(...)
{
for (size_type __j = 1; __j < __i; ++__j)
! _M_deallocate_node(*(this->_M_impl._M_start._M_node - __j));
__throw_exception_again;
}
}
--- 637,648 ----
try
{
for (__i = 1; __i <= __new_nodes; ++__i)
! *(this->_M_start._M_node - __i) = this->_M_allocate_node();
}
catch(...)
{
for (size_type __j = 1; __j < __i; ++__j)
! _M_deallocate_node(*(this->_M_start._M_node - __j));
__throw_exception_again;
}
}
*************** namespace __gnu_norm
*** 659,670 ****
try
{
for (__i = 1; __i <= __new_nodes; ++__i)
! *(this->_M_impl._M_finish._M_node + __i) = this->_M_allocate_node();
}
catch(...)
{
for (size_type __j = 1; __j < __i; ++__j)
! _M_deallocate_node(*(this->_M_impl._M_finish._M_node + __j));
__throw_exception_again;
}
}
--- 659,670 ----
try
{
for (__i = 1; __i <= __new_nodes; ++__i)
! *(this->_M_finish._M_node + __i) = this->_M_allocate_node();
}
catch(...)
{
for (size_type __j = 1; __j < __i; ++__j)
! _M_deallocate_node(*(this->_M_finish._M_node + __j));
__throw_exception_again;
}
}
*************** namespace __gnu_norm
*** 675,718 ****
_M_reallocate_map(size_type __nodes_to_add, bool __add_at_front)
{
size_type __old_num_nodes
! = this->_M_impl._M_finish._M_node - this->_M_impl._M_start._M_node + 1;
size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;
_Map_pointer __new_nstart;
! if (this->_M_impl._M_map_size > 2 * __new_num_nodes)
{
! __new_nstart = this->_M_impl._M_map + (this->_M_impl._M_map_size
- __new_num_nodes) / 2
+ (__add_at_front ? __nodes_to_add : 0);
! if (__new_nstart < this->_M_impl._M_start._M_node)
! std::copy(this->_M_impl._M_start._M_node,
! this->_M_impl._M_finish._M_node + 1,
__new_nstart);
else
! std::copy_backward(this->_M_impl._M_start._M_node,
! this->_M_impl._M_finish._M_node + 1,
__new_nstart + __old_num_nodes);
}
else
{
! size_type __new_map_size = this->_M_impl._M_map_size
! + std::max(this->_M_impl._M_map_size,
__nodes_to_add) + 2;
_Map_pointer __new_map = this->_M_allocate_map(__new_map_size);
__new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
+ (__add_at_front ? __nodes_to_add : 0);
! std::copy(this->_M_impl._M_start._M_node,
! this->_M_impl._M_finish._M_node + 1,
__new_nstart);
! _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
! this->_M_impl._M_map = __new_map;
! this->_M_impl._M_map_size = __new_map_size;
}
! this->_M_impl._M_start._M_set_node(__new_nstart);
! this->_M_impl._M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
}
} // namespace __gnu_norm
--- 675,718 ----
_M_reallocate_map(size_type __nodes_to_add, bool __add_at_front)
{
size_type __old_num_nodes
! = this->_M_finish._M_node - this->_M_start._M_node + 1;
size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;
_Map_pointer __new_nstart;
! if (this->_M_map_size > 2 * __new_num_nodes)
{
! __new_nstart = this->_M_map + (this->_M_map_size
- __new_num_nodes) / 2
+ (__add_at_front ? __nodes_to_add : 0);
! if (__new_nstart < this->_M_start._M_node)
! std::copy(this->_M_start._M_node,
! this->_M_finish._M_node + 1,
__new_nstart);
else
! std::copy_backward(this->_M_start._M_node,
! this->_M_finish._M_node + 1,
__new_nstart + __old_num_nodes);
}
else
{
! size_type __new_map_size = this->_M_map_size
! + std::max(this->_M_map_size,
__nodes_to_add) + 2;
_Map_pointer __new_map = this->_M_allocate_map(__new_map_size);
__new_nstart = __new_map + (__new_map_size - __new_num_nodes) / 2
+ (__add_at_front ? __nodes_to_add : 0);
! std::copy(this->_M_start._M_node,
! this->_M_finish._M_node + 1,
__new_nstart);
! _M_deallocate_map(this->_M_map, this->_M_map_size);
! this->_M_map = __new_map;
! this->_M_map_size = __new_map_size;
}
! this->_M_start._M_set_node(__new_nstart);
! this->_M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
}
} // namespace __gnu_norm
diff -Nrcp -x '*cvs*' ./include/bits/list.tcc /home/dhruv/projects/cvs_libstdc++-v3/include/bits/list.tcc
*** ./include/bits/list.tcc 2004-03-25 15:14:00.000000000 +0530
--- /home/dhruv/projects/cvs_libstdc++-v3/include/bits/list.tcc 2004-02-08 10:16:41.000000000 +0530
*************** namespace __gnu_norm
*** 69,76 ****
_M_clear()
{
typedef _List_node<_Tp> _Node;
! _Node* __cur = static_cast<_Node*>(this->_M_impl._M_node._M_next);
! while (__cur != &this->_M_impl._M_node)
{
_Node* __tmp = __cur;
__cur = static_cast<_Node*>(__cur->_M_next);
--- 69,76 ----
_M_clear()
{
typedef _List_node<_Tp> _Node;
! _Node* __cur = static_cast<_Node*>(this->_M_node._M_next);
! while (__cur != &this->_M_node)
{
_Node* __tmp = __cur;
__cur = static_cast<_Node*>(__cur->_M_next);
*************** namespace __gnu_norm
*** 237,244 ****
sort()
{
// Do nothing if the list has length 0 or 1.
! if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
! && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
{
list __carry;
list __tmp[64];
--- 237,244 ----
sort()
{
// Do nothing if the list has length 0 or 1.
! if (this->_M_node._M_next != &this->_M_node
! && this->_M_node._M_next->_M_next != &this->_M_node)
{
list __carry;
list __tmp[64];
*************** namespace __gnu_norm
*** 341,348 ****
sort(_StrictWeakOrdering __comp)
{
// Do nothing if the list has length 0 or 1.
! if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
! && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
{
list __carry;
list __tmp[64];
--- 341,348 ----
sort(_StrictWeakOrdering __comp)
{
// Do nothing if the list has length 0 or 1.
! if (this->_M_node._M_next != &this->_M_node
! && this->_M_node._M_next->_M_next != &this->_M_node)
{
list __carry;
list __tmp[64];
diff -Nrcp -x '*cvs*' ./include/bits/stl_deque.h /home/dhruv/projects/cvs_libstdc++-v3/include/bits/stl_deque.h
*** ./include/bits/stl_deque.h 2004-03-25 15:26:05.000000000 +0530
--- /home/dhruv/projects/cvs_libstdc++-v3/include/bits/stl_deque.h 2004-02-08 10:16:41.000000000 +0530
*************** namespace __gnu_norm
*** 351,404 ****
*/
template<typename _Tp, typename _Alloc>
class _Deque_base
{
public:
typedef _Alloc allocator_type;
allocator_type
get_allocator() const
! { return *static_cast<const _Alloc*>(&this->_M_impl); }
typedef _Deque_iterator<_Tp,_Tp&,_Tp*> iterator;
typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;
_Deque_base(const allocator_type& __a, size_t __num_elements)
! : _M_impl(__a)
{ _M_initialize_map(__num_elements); }
_Deque_base(const allocator_type& __a)
! : _M_impl(__a)
! { }
~_Deque_base();
protected:
- //This struct encapsulates the implementation of the std::deque
- //standard container and at the same time makes use of the EBO
- //for empty allocators.
- struct _Deque_impl
- : public _Alloc {
- _Tp** _M_map;
- size_t _M_map_size;
- iterator _M_start;
- iterator _M_finish;
-
- _Deque_impl(const _Alloc& __a)
- : _Alloc(__a), _M_map(0), _M_map_size(0), _M_start(), _M_finish()
- { }
- };
-
typedef typename _Alloc::template rebind<_Tp*>::other _Map_alloc_type;
_Map_alloc_type _M_get_map_allocator() const
{ return _Map_alloc_type(this->get_allocator()); }
_Tp*
_M_allocate_node()
! { return _M_impl._Alloc::allocate(__deque_buf_size(sizeof(_Tp))); }
void
_M_deallocate_node(_Tp* __p)
! { _M_impl._Alloc::deallocate(__p, __deque_buf_size(sizeof(_Tp))); }
_Tp**
_M_allocate_map(size_t __n)
--- 351,389 ----
*/
template<typename _Tp, typename _Alloc>
class _Deque_base
+ : public _Alloc
{
public:
typedef _Alloc allocator_type;
allocator_type
get_allocator() const
! { return *static_cast<const _Alloc*>(this); }
typedef _Deque_iterator<_Tp,_Tp&,_Tp*> iterator;
typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator;
_Deque_base(const allocator_type& __a, size_t __num_elements)
! : _Alloc(__a), _M_start(), _M_finish()
{ _M_initialize_map(__num_elements); }
_Deque_base(const allocator_type& __a)
! : _Alloc(__a), _M_start(), _M_finish() { }
~_Deque_base();
protected:
typedef typename _Alloc::template rebind<_Tp*>::other _Map_alloc_type;
_Map_alloc_type _M_get_map_allocator() const
{ return _Map_alloc_type(this->get_allocator()); }
_Tp*
_M_allocate_node()
! { return _Alloc::allocate(__deque_buf_size(sizeof(_Tp))); }
void
_M_deallocate_node(_Tp* __p)
! { _Alloc::deallocate(__p, __deque_buf_size(sizeof(_Tp))); }
_Tp**
_M_allocate_map(size_t __n)
*************** namespace __gnu_norm
*** 414,429 ****
void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish);
enum { _S_initial_map_size = 8 };
! _Deque_impl _M_impl;
};
template<typename _Tp, typename _Alloc>
_Deque_base<_Tp,_Alloc>::~_Deque_base()
{
! if (this->_M_impl._M_map)
{
! _M_destroy_nodes(this->_M_impl._M_start._M_node, this->_M_impl._M_finish._M_node + 1);
! _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
}
}
--- 399,417 ----
void _M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish);
enum { _S_initial_map_size = 8 };
! _Tp** _M_map;
! size_t _M_map_size;
! iterator _M_start;
! iterator _M_finish;
};
template<typename _Tp, typename _Alloc>
_Deque_base<_Tp,_Alloc>::~_Deque_base()
{
! if (this->_M_map)
{
! _M_destroy_nodes(_M_start._M_node, _M_finish._M_node + 1);
! _M_deallocate_map(this->_M_map, this->_M_map_size);
}
}
*************** namespace __gnu_norm
*** 443,474 ****
{
size_t __num_nodes = __num_elements / __deque_buf_size(sizeof(_Tp)) + 1;
! this->_M_impl._M_map_size = std::max((size_t) _S_initial_map_size,
__num_nodes + 2);
! this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size);
// For "small" maps (needing less than _M_map_size nodes), allocation
// starts in the middle elements and grows outwards. So nstart may be
// the beginning of _M_map, but for small maps it may be as far in as
// _M_map+3.
! _Tp** __nstart = this->_M_impl._M_map + (this->_M_impl._M_map_size - __num_nodes) / 2;
_Tp** __nfinish = __nstart + __num_nodes;
try
{ _M_create_nodes(__nstart, __nfinish); }
catch(...)
{
! _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
! this->_M_impl._M_map = 0;
! this->_M_impl._M_map_size = 0;
__throw_exception_again;
}
! this->_M_impl._M_start._M_set_node(__nstart);
! this->_M_impl._M_finish._M_set_node(__nfinish - 1);
! this->_M_impl._M_start._M_cur = _M_impl._M_start._M_first;
! this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_first + __num_elements
% __deque_buf_size(sizeof(_Tp));
}
--- 431,462 ----
{
size_t __num_nodes = __num_elements / __deque_buf_size(sizeof(_Tp)) + 1;
! this->_M_map_size = std::max((size_t) _S_initial_map_size,
__num_nodes + 2);
! this->_M_map = _M_allocate_map(this->_M_map_size);
// For "small" maps (needing less than _M_map_size nodes), allocation
// starts in the middle elements and grows outwards. So nstart may be
// the beginning of _M_map, but for small maps it may be as far in as
// _M_map+3.
! _Tp** __nstart = this->_M_map + (this->_M_map_size - __num_nodes) / 2;
_Tp** __nfinish = __nstart + __num_nodes;
try
{ _M_create_nodes(__nstart, __nfinish); }
catch(...)
{
! _M_deallocate_map(this->_M_map, this->_M_map_size);
! this->_M_map = 0;
! this->_M_map_size = 0;
__throw_exception_again;
}
! _M_start._M_set_node(__nstart);
! _M_finish._M_set_node(__nfinish - 1);
! _M_start._M_cur = _M_start._M_first;
! _M_finish._M_cur = _M_finish._M_first + __num_elements
% __deque_buf_size(sizeof(_Tp));
}
*************** namespace __gnu_norm
*** 620,629 ****
/** @if maint
* A total of four data members accumulated down the heirarchy.
- * May be accessed via _M_impl.*
* @endif
*/
! using _Base::_M_impl;
public:
// [23.2.1.1] construct/copy/destroy
--- 608,619 ----
/** @if maint
* A total of four data members accumulated down the heirarchy.
* @endif
*/
! using _Base::_M_map;
! using _Base::_M_map_size;
! using _Base::_M_start;
! using _Base::_M_finish;
public:
// [23.2.1.1] construct/copy/destroy
*************** namespace __gnu_norm
*** 668,674 ****
*/
deque(const deque& __x)
: _Base(__x.get_allocator(), __x.size())
! { std::uninitialized_copy(__x.begin(), __x.end(), this->_M_impl._M_start); }
/**
* @brief Builds a %deque from a range.
--- 658,664 ----
*/
deque(const deque& __x)
: _Base(__x.get_allocator(), __x.size())
! { std::uninitialized_copy(__x.begin(), __x.end(), this->_M_start); }
/**
* @brief Builds a %deque from a range.
*************** namespace __gnu_norm
*** 700,706 ****
* way. Managing the pointer is the user's responsibilty.
*/
~deque()
! { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); }
/**
* @brief %Deque assignment operator.
--- 690,696 ----
* way. Managing the pointer is the user's responsibilty.
*/
~deque()
! { std::_Destroy(this->_M_start, this->_M_finish); }
/**
* @brief %Deque assignment operator.
*************** namespace __gnu_norm
*** 758,764 ****
*/
iterator
begin()
! { return this->_M_impl._M_start; }
/**
* Returns a read-only (constant) iterator that points to the first
--- 748,754 ----
*/
iterator
begin()
! { return this->_M_start; }
/**
* Returns a read-only (constant) iterator that points to the first
*************** namespace __gnu_norm
*** 766,772 ****
*/
const_iterator
begin() const
! { return this->_M_impl._M_start; }
/**
* Returns a read/write iterator that points one past the last element in
--- 756,762 ----
*/
const_iterator
begin() const
! { return this->_M_start; }
/**
* Returns a read/write iterator that points one past the last element in
*************** namespace __gnu_norm
*** 774,780 ****
*/
iterator
end()
! { return this->_M_impl._M_finish; }
/**
* Returns a read-only (constant) iterator that points one past the last
--- 764,770 ----
*/
iterator
end()
! { return this->_M_finish; }
/**
* Returns a read-only (constant) iterator that points one past the last
*************** namespace __gnu_norm
*** 782,788 ****
*/
const_iterator
end() const
! { return this->_M_impl._M_finish; }
/**
* Returns a read/write reverse iterator that points to the last element
--- 772,778 ----
*/
const_iterator
end() const
! { return this->_M_finish; }
/**
* Returns a read/write reverse iterator that points to the last element
*************** namespace __gnu_norm
*** 790,796 ****
*/
reverse_iterator
rbegin()
! { return reverse_iterator(this->_M_impl._M_finish); }
/**
* Returns a read-only (constant) reverse iterator that points to the
--- 780,786 ----
*/
reverse_iterator
rbegin()
! { return reverse_iterator(this->_M_finish); }
/**
* Returns a read-only (constant) reverse iterator that points to the
*************** namespace __gnu_norm
*** 799,805 ****
*/
const_reverse_iterator
rbegin() const
! { return const_reverse_iterator(this->_M_impl._M_finish); }
/**
* Returns a read/write reverse iterator that points to one before the
--- 789,795 ----
*/
const_reverse_iterator
rbegin() const
! { return const_reverse_iterator(this->_M_finish); }
/**
* Returns a read/write reverse iterator that points to one before the
*************** namespace __gnu_norm
*** 807,813 ****
* order.
*/
reverse_iterator
! rend() { return reverse_iterator(this->_M_impl._M_start); }
/**
* Returns a read-only (constant) reverse iterator that points to one
--- 797,803 ----
* order.
*/
reverse_iterator
! rend() { return reverse_iterator(this->_M_start); }
/**
* Returns a read-only (constant) reverse iterator that points to one
*************** namespace __gnu_norm
*** 816,828 ****
*/
const_reverse_iterator
rend() const
! { return const_reverse_iterator(this->_M_impl._M_start); }
// [23.2.1.2] capacity
/** Returns the number of elements in the %deque. */
size_type
size() const
! { return this->_M_impl._M_finish - this->_M_impl._M_start; }
/** Returns the size() of the largest possible %deque. */
size_type
--- 806,818 ----
*/
const_reverse_iterator
rend() const
! { return const_reverse_iterator(this->_M_start); }
// [23.2.1.2] capacity
/** Returns the number of elements in the %deque. */
size_type
size() const
! { return this->_M_finish - this->_M_start; }
/** Returns the size() of the largest possible %deque. */
size_type
*************** namespace __gnu_norm
*** 844,852 ****
{
const size_type __len = size();
if (__new_size < __len)
! erase(this->_M_impl._M_start + __new_size, this->_M_impl._M_finish);
else
! insert(this->_M_impl._M_finish, __new_size - __len, __x);
}
/**
--- 834,842 ----
{
const size_type __len = size();
if (__new_size < __len)
! erase(this->_M_start + __new_size, this->_M_finish);
else
! insert(this->_M_finish, __new_size - __len, __x);
}
/**
*************** namespace __gnu_norm
*** 867,873 ****
*/
bool
empty() const
! { return this->_M_impl._M_finish == this->_M_impl._M_start; }
// element access
/**
--- 857,863 ----
*/
bool
empty() const
! { return this->_M_finish == this->_M_start; }
// element access
/**
*************** namespace __gnu_norm
*** 881,887 ****
*/
reference
operator[](size_type __n)
! { return this->_M_impl._M_start[difference_type(__n)]; }
/**
* @brief Subscript access to the data contained in the %deque.
--- 871,877 ----
*/
reference
operator[](size_type __n)
! { return this->_M_start[difference_type(__n)]; }
/**
* @brief Subscript access to the data contained in the %deque.
*************** namespace __gnu_norm
*** 894,900 ****
*/
const_reference
operator[](size_type __n) const
! { return this->_M_impl._M_start[difference_type(__n)]; }
protected:
/// @if maint Safety check used only from at(). @endif
--- 884,890 ----
*/
const_reference
operator[](size_type __n) const
! { return this->_M_start[difference_type(__n)]; }
protected:
/// @if maint Safety check used only from at(). @endif
*************** namespace __gnu_norm
*** 943,949 ****
*/
reference
front()
! { return *this->_M_impl._M_start; }
/**
* Returns a read-only (constant) reference to the data at the first
--- 933,939 ----
*/
reference
front()
! { return *this->_M_start; }
/**
* Returns a read-only (constant) reference to the data at the first
*************** namespace __gnu_norm
*** 951,957 ****
*/
const_reference
front() const
! { return *this->_M_impl._M_start; }
/**
* Returns a read/write reference to the data at the last element of the
--- 941,947 ----
*/
const_reference
front() const
! { return *this->_M_start; }
/**
* Returns a read/write reference to the data at the last element of the
*************** namespace __gnu_norm
*** 960,966 ****
reference
back()
{
! iterator __tmp = this->_M_impl._M_finish;
--__tmp;
return *__tmp;
}
--- 950,956 ----
reference
back()
{
! iterator __tmp = this->_M_finish;
--__tmp;
return *__tmp;
}
*************** namespace __gnu_norm
*** 972,978 ****
const_reference
back() const
{
! const_iterator __tmp = this->_M_impl._M_finish;
--__tmp;
return *__tmp;
}
--- 962,968 ----
const_reference
back() const
{
! const_iterator __tmp = this->_M_finish;
--__tmp;
return *__tmp;
}
*************** namespace __gnu_norm
*** 989,998 ****
void
push_front(const value_type& __x)
{
! if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_first)
{
! std::_Construct(this->_M_impl._M_start._M_cur - 1, __x);
! --this->_M_impl._M_start._M_cur;
}
else
_M_push_front_aux(__x);
--- 979,988 ----
void
push_front(const value_type& __x)
{
! if (this->_M_start._M_cur != this->_M_start._M_first)
{
! std::_Construct(this->_M_start._M_cur - 1, __x);
! --this->_M_start._M_cur;
}
else
_M_push_front_aux(__x);
*************** namespace __gnu_norm
*** 1009,1018 ****
void
push_back(const value_type& __x)
{
! if (this->_M_impl._M_finish._M_cur != this->_M_impl._M_finish._M_last - 1)
{
! std::_Construct(this->_M_impl._M_finish._M_cur, __x);
! ++this->_M_impl._M_finish._M_cur;
}
else
_M_push_back_aux(__x);
--- 999,1008 ----
void
push_back(const value_type& __x)
{
! if (this->_M_finish._M_cur != this->_M_finish._M_last - 1)
{
! std::_Construct(this->_M_finish._M_cur, __x);
! ++this->_M_finish._M_cur;
}
else
_M_push_back_aux(__x);
*************** namespace __gnu_norm
*** 1029,1038 ****
void
pop_front()
{
! if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_last - 1)
{
! std::_Destroy(this->_M_impl._M_start._M_cur);
! ++this->_M_impl._M_start._M_cur;
}
else
_M_pop_front_aux();
--- 1019,1028 ----
void
pop_front()
{
! if (this->_M_start._M_cur != this->_M_start._M_last - 1)
{
! std::_Destroy(this->_M_start._M_cur);
! ++this->_M_start._M_cur;
}
else
_M_pop_front_aux();
*************** namespace __gnu_norm
*** 1049,1058 ****
void
pop_back()
{
! if (this->_M_impl._M_finish._M_cur != this->_M_impl._M_finish._M_first)
{
! --this->_M_impl._M_finish._M_cur;
! std::_Destroy(this->_M_impl._M_finish._M_cur);
}
else
_M_pop_back_aux();
--- 1039,1048 ----
void
pop_back()
{
! if (this->_M_finish._M_cur != this->_M_finish._M_first)
{
! --this->_M_finish._M_cur;
! std::_Destroy(this->_M_finish._M_cur);
}
else
_M_pop_back_aux();
*************** namespace __gnu_norm
*** 1150,1159 ****
void
swap(deque& __x)
{
! std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
! std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
! std::swap(this->_M_impl._M_map, __x._M_impl._M_map);
! std::swap(this->_M_impl._M_map_size, __x._M_impl._M_map_size);
}
/**
--- 1140,1149 ----
void
swap(deque& __x)
{
! std::swap(this->_M_start, __x._M_start);
! std::swap(this->_M_finish, __x._M_finish);
! std::swap(this->_M_map, __x._M_map);
! std::swap(this->_M_map_size, __x._M_map_size);
}
/**
*************** namespace __gnu_norm
*** 1372,1392 ****
iterator
_M_reserve_elements_at_front(size_type __n)
{
! const size_type __vacancies = this->_M_impl._M_start._M_cur
! - this->_M_impl._M_start._M_first;
if (__n > __vacancies)
_M_new_elements_at_front(__n - __vacancies);
! return this->_M_impl._M_start - difference_type(__n);
}
iterator
_M_reserve_elements_at_back(size_type __n)
{
! const size_type __vacancies = (this->_M_impl._M_finish._M_last
! - this->_M_impl._M_finish._M_cur) - 1;
if (__n > __vacancies)
_M_new_elements_at_back(__n - __vacancies);
! return this->_M_impl._M_finish + difference_type(__n);
}
void
--- 1362,1382 ----
iterator
_M_reserve_elements_at_front(size_type __n)
{
! const size_type __vacancies = this->_M_start._M_cur
! - this->_M_start._M_first;
if (__n > __vacancies)
_M_new_elements_at_front(__n - __vacancies);
! return this->_M_start - difference_type(__n);
}
iterator
_M_reserve_elements_at_back(size_type __n)
{
! const size_type __vacancies = (this->_M_finish._M_last
! - this->_M_finish._M_cur) - 1;
if (__n > __vacancies)
_M_new_elements_at_back(__n - __vacancies);
! return this->_M_finish + difference_type(__n);
}
void
*************** namespace __gnu_norm
*** 1410,1424 ****
void
_M_reserve_map_at_back (size_type __nodes_to_add = 1)
{
! if (__nodes_to_add + 1 > this->_M_impl._M_map_size
! - (this->_M_impl._M_finish._M_node - this->_M_impl._M_map))
_M_reallocate_map(__nodes_to_add, false);
}
void
_M_reserve_map_at_front (size_type __nodes_to_add = 1)
{
! if (__nodes_to_add > size_type(this->_M_impl._M_start._M_node - this->_M_impl._M_map))
_M_reallocate_map(__nodes_to_add, true);
}
--- 1400,1414 ----
void
_M_reserve_map_at_back (size_type __nodes_to_add = 1)
{
! if (__nodes_to_add + 1 > this->_M_map_size
! - (this->_M_finish._M_node - this->_M_map))
_M_reallocate_map(__nodes_to_add, false);
}
void
_M_reserve_map_at_front (size_type __nodes_to_add = 1)
{
! if (__nodes_to_add > size_type(this->_M_start._M_node - this->_M_map))
_M_reallocate_map(__nodes_to_add, true);
}
diff -Nrcp -x '*cvs*' ./include/bits/stl_list.h /home/dhruv/projects/cvs_libstdc++-v3/include/bits/stl_list.h
*** ./include/bits/stl_list.h 2004-03-25 15:22:13.000000000 +0530
--- /home/dhruv/projects/cvs_libstdc++-v3/include/bits/stl_list.h 2004-02-08 10:16:42.000000000 +0530
*************** namespace __gnu_norm
*** 275,280 ****
--- 275,281 ----
*/
template<typename _Tp, typename _Alloc>
class _List_base
+ : public _Alloc::template rebind<_List_node<_Tp> >::other
{
protected:
// NOTA BENE
*************** namespace __gnu_norm
*** 294,326 ****
_Node_Alloc_type;
! struct _List_impl
! : public _Node_Alloc_type {
! _List_node_base _M_node;
! _List_impl (const _Node_Alloc_type& __a)
! : _Node_Alloc_type(__a)
! { }
! };
!
! _List_impl _M_impl;
_List_node<_Tp>*
_M_get_node()
! { return _M_impl._Node_Alloc_type::allocate(1); }
!
void
_M_put_node(_List_node<_Tp>* __p)
! { _M_impl._Node_Alloc_type::deallocate(__p, 1); }
!
public:
typedef _Alloc allocator_type;
allocator_type
get_allocator() const
! { return allocator_type(*static_cast<const _Node_Alloc_type*>(&this->_M_impl)); }
_List_base(const allocator_type& __a)
! : _M_impl(__a)
{ _M_init(); }
// This is what actually destroys the list.
--- 295,319 ----
_Node_Alloc_type;
! _List_node_base _M_node;
_List_node<_Tp>*
_M_get_node()
! { return _Node_Alloc_type::allocate(1); }
!
void
_M_put_node(_List_node<_Tp>* __p)
! { _Node_Alloc_type::deallocate(__p, 1); }
!
public:
typedef _Alloc allocator_type;
allocator_type
get_allocator() const
! { return allocator_type(*static_cast<const _Node_Alloc_type*>(this)); }
_List_base(const allocator_type& __a)
! : _Node_Alloc_type(__a)
{ _M_init(); }
// This is what actually destroys the list.
*************** namespace __gnu_norm
*** 333,340 ****
void
_M_init()
{
! this->_M_impl._M_node._M_next = &this->_M_impl._M_node;
! this->_M_impl._M_node._M_prev = &this->_M_impl._M_node;
}
};
--- 326,333 ----
void
_M_init()
{
! this->_M_node._M_next = &this->_M_node;
! this->_M_node._M_prev = &this->_M_node;
}
};
*************** namespace __gnu_norm
*** 416,422 ****
* will also be included, accumulated from the topmost parent.
* @endif
*/
! using _Base::_M_impl;
using _Base::_M_put_node;
using _Base::_M_get_node;
--- 409,415 ----
* will also be included, accumulated from the topmost parent.
* @endif
*/
! using _Base::_M_node;
using _Base::_M_put_node;
using _Base::_M_get_node;
*************** namespace __gnu_norm
*** 595,601 ****
*/
iterator
begin()
! { return this->_M_impl._M_node._M_next; }
/**
* Returns a read-only (constant) iterator that points to the
--- 588,594 ----
*/
iterator
begin()
! { return this->_M_node._M_next; }
/**
* Returns a read-only (constant) iterator that points to the
*************** namespace __gnu_norm
*** 604,610 ****
*/
const_iterator
begin() const
! { return this->_M_impl._M_node._M_next; }
/**
* Returns a read/write iterator that points one past the last
--- 597,603 ----
*/
const_iterator
begin() const
! { return this->_M_node._M_next; }
/**
* Returns a read/write iterator that points one past the last
*************** namespace __gnu_norm
*** 612,618 ****
* order.
*/
iterator
! end() { return &this->_M_impl._M_node; }
/**
* Returns a read-only (constant) iterator that points one past
--- 605,611 ----
* order.
*/
iterator
! end() { return &this->_M_node; }
/**
* Returns a read-only (constant) iterator that points one past
*************** namespace __gnu_norm
*** 621,627 ****
*/
const_iterator
end() const
! { return &this->_M_impl._M_node; }
/**
* Returns a read/write reverse iterator that points to the last
--- 614,620 ----
*/
const_iterator
end() const
! { return &this->_M_node; }
/**
* Returns a read/write reverse iterator that points to the last
*************** namespace __gnu_norm
*** 666,672 ****
*/
bool
empty() const
! { return this->_M_impl._M_node._M_next == &this->_M_impl._M_node; }
/** Returns the number of elements in the %list. */
size_type
--- 659,665 ----
*/
bool
empty() const
! { return this->_M_node._M_next == &this->_M_node; }
/** Returns the number of elements in the %list. */
size_type
*************** namespace __gnu_norm
*** 795,801 ****
*/
void
pop_back()
! { this->_M_erase(this->_M_impl._M_node._M_prev); }
/**
* @brief Inserts given value into %list before specified iterator.
--- 788,794 ----
*/
void
pop_back()
! { this->_M_erase(this->_M_node._M_prev); }
/**
* @brief Inserts given value into %list before specified iterator.
*************** namespace __gnu_norm
*** 908,914 ****
*/
void
swap(list& __x)
! { _List_node_base::swap(this->_M_impl._M_node,__x._M_impl._M_node); }
/**
* Erases all the elements. Note that this function only erases
--- 901,907 ----
*/
void
swap(list& __x)
! { _List_node_base::swap(this->_M_node,__x._M_node); }
/**
* Erases all the elements. Note that this function only erases
*************** namespace __gnu_norm
*** 1071,1077 ****
*/
void
reverse()
! { this->_M_impl._M_node.reverse(); }
/**
* @brief Sort the elements.
--- 1064,1070 ----
*/
void
reverse()
! { this->_M_node.reverse(); }
/**
* @brief Sort the elements.
diff -Nrcp -x '*cvs*' ./include/bits/stl_tree.h /home/dhruv/projects/cvs_libstdc++-v3/include/bits/stl_tree.h
*** ./include/bits/stl_tree.h 2004-03-25 15:20:26.000000000 +0530
--- /home/dhruv/projects/cvs_libstdc++-v3/include/bits/stl_tree.h 2004-02-08 10:16:42.000000000 +0530
*************** iterators invalidated are those referrin
*** 87,93 ****
#include <bits/allocator.h>
#include <bits/stl_construct.h>
#include <bits/stl_function.h>
- #include <bits/cpp_type_traits.h>
namespace std
{
--- 87,92 ----
*************** namespace std
*** 326,331 ****
--- 325,331 ----
template<typename _Key, typename _Val, typename _KeyOfValue,
typename _Compare, typename _Alloc = allocator<_Val> >
class _Rb_tree
+ : protected _Alloc::template rebind<_Rb_tree_node<_Val> >::other
{
typedef typename _Alloc::template rebind<_Rb_tree_node<_Val> >::other
_Node_allocator;
*************** namespace std
*** 349,364 ****
typedef _Alloc allocator_type;
allocator_type get_allocator() const
! { return *static_cast<const _Node_allocator*>(&this->_M_impl); }
protected:
_Rb_tree_node*
_M_get_node()
! { return _M_impl._Node_allocator::allocate(1); }
void
_M_put_node(_Rb_tree_node* __p)
! { _M_impl._Node_allocator::deallocate(__p, 1); }
_Link_type
_M_create_node(const value_type& __x)
--- 349,364 ----
typedef _Alloc allocator_type;
allocator_type get_allocator() const
! { return *static_cast<const _Node_allocator*>(this); }
protected:
_Rb_tree_node*
_M_get_node()
! { return _Node_allocator::allocate(1); }
void
_M_put_node(_Rb_tree_node* __p)
! { _Node_allocator::deallocate(__p, 1); }
_Link_type
_M_create_node(const value_type& __x)
*************** namespace std
*** 392,474 ****
}
protected:
! template <typename _Key_compare,
! bool _Is_pod_comparator = std::__is_pod<_Key_compare>::_M_type >
! struct _Rb_tree_impl
! : public _Node_allocator, public _Key_compare {
! _Rb_tree_node_base _M_header;
! size_type _M_node_count; // keeps track of size of tree
!
! _Key_compare&
! _M_key_compare()
! { return static_cast<_Key_compare&>(*this); }
!
! _Rb_tree_impl (const _Node_allocator& __a, const _Key_compare& __comp = _Key_compare())
! : _Node_allocator(__a), _Key_compare(__comp), _M_node_count(0)
! { }
! };
!
! //Specialization for _Comparison types that are not capable of
! //being base classes / super classes.
! template <typename _Key_compare>
! struct _Rb_tree_impl <_Key_compare, true>
! : public _Node_allocator {
! _Key_compare _M_key_compare_data;
! _Rb_tree_node_base _M_header;
! size_type _M_node_count; // keeps track of size of tree
!
! _Key_compare&
! _M_key_compare()
! { return _M_key_compare_data; }
!
! _Rb_tree_impl (const _Node_allocator& __a = _Node_allocator(),
! const _Key_compare& __comp = _Key_compare())
! : _Node_allocator(__a), _M_key_compare_data(__comp), _M_node_count(0)
! { }
! };
!
! _Rb_tree_impl<_Compare> _M_impl;
protected:
_Base_ptr&
_M_root()
! { return this->_M_impl._M_header._M_parent; }
_Const_Base_ptr
_M_root() const
! { return this->_M_impl._M_header._M_parent; }
_Base_ptr&
_M_leftmost()
! { return this->_M_impl._M_header._M_left; }
_Const_Base_ptr
_M_leftmost() const
! { return this->_M_impl._M_header._M_left; }
_Base_ptr&
_M_rightmost()
! { return this->_M_impl._M_header._M_right; }
_Const_Base_ptr
_M_rightmost() const
! { return this->_M_impl._M_header._M_right; }
_Link_type
_M_begin()
! { return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); }
_Const_Link_type
_M_begin() const
! { return static_cast<_Const_Link_type>(this->_M_impl._M_header._M_parent); }
_Link_type
_M_end()
! { return static_cast<_Link_type>(&this->_M_impl._M_header); }
_Const_Link_type
_M_end() const
! { return static_cast<_Const_Link_type>(&this->_M_impl._M_header); }
static const_reference
_S_value(_Const_Link_type __x)
--- 392,441 ----
}
protected:
! _Rb_tree_node_base _M_header;
! size_type _M_node_count; // keeps track of size of tree
! _Compare _M_key_compare;
protected:
_Base_ptr&
_M_root()
! { return this->_M_header._M_parent; }
_Const_Base_ptr
_M_root() const
! { return this->_M_header._M_parent; }
_Base_ptr&
_M_leftmost()
! { return this->_M_header._M_left; }
_Const_Base_ptr
_M_leftmost() const
! { return this->_M_header._M_left; }
_Base_ptr&
_M_rightmost()
! { return this->_M_header._M_right; }
_Const_Base_ptr
_M_rightmost() const
! { return this->_M_header._M_right; }
_Link_type
_M_begin()
! { return static_cast<_Link_type>(this->_M_header._M_parent); }
_Const_Link_type
_M_begin() const
! { return static_cast<_Const_Link_type>(this->_M_header._M_parent); }
_Link_type
_M_end()
! { return static_cast<_Link_type>(&this->_M_header); }
_Const_Link_type
_M_end() const
! { return static_cast<_Const_Link_type>(&this->_M_header); }
static const_reference
_S_value(_Const_Link_type __x)
*************** namespace std
*** 538,566 ****
public:
// allocation/deallocation
_Rb_tree()
{ _M_empty_initialize(); }
_Rb_tree(const _Compare& __comp)
! : _M_impl(allocator_type(), __comp)
{ _M_empty_initialize(); }
_Rb_tree(const _Compare& __comp, const allocator_type& __a)
! : _M_impl(__a, __comp)
{ _M_empty_initialize(); }
_Rb_tree(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x)
! : _M_impl(__x.get_allocator(), __x._M_impl._M_key_compare())
{
if (__x._M_root() == 0)
_M_empty_initialize();
else
{
! this->_M_impl._M_header._M_color = _S_red;
_M_root() = _M_copy(__x._M_begin(), _M_end());
_M_leftmost() = _S_minimum(_M_root());
_M_rightmost() = _S_maximum(_M_root());
}
! _M_impl._M_node_count = __x._M_impl._M_node_count;
}
~_Rb_tree()
--- 505,542 ----
public:
// allocation/deallocation
_Rb_tree()
+ : _Node_allocator(allocator_type()),
+ _M_node_count(0),
+ _M_key_compare()
{ _M_empty_initialize(); }
_Rb_tree(const _Compare& __comp)
! : _Node_allocator(allocator_type()),
! _M_node_count(0),
! _M_key_compare(__comp)
{ _M_empty_initialize(); }
_Rb_tree(const _Compare& __comp, const allocator_type& __a)
! : _Node_allocator(__a),
! _M_node_count(0),
! _M_key_compare(__comp)
{ _M_empty_initialize(); }
_Rb_tree(const _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>& __x)
! : _Node_allocator(__x.get_allocator()),
! _M_node_count(0),
! _M_key_compare(__x._M_key_compare)
{
if (__x._M_root() == 0)
_M_empty_initialize();
else
{
! this->_M_header._M_color = _S_red;
_M_root() = _M_copy(__x._M_begin(), _M_end());
_M_leftmost() = _S_minimum(_M_root());
_M_rightmost() = _S_maximum(_M_root());
}
! _M_node_count = __x._M_node_count;
}
~_Rb_tree()
*************** namespace std
*** 573,579 ****
void _M_empty_initialize()
{
// Used to distinguish header from __root, in iterator.operator++.
! this->_M_impl._M_header._M_color = _S_red;
_M_root() = 0;
_M_leftmost() = _M_end();
_M_rightmost() = _M_end();
--- 549,555 ----
void _M_empty_initialize()
{
// Used to distinguish header from __root, in iterator.operator++.
! this->_M_header._M_color = _S_red;
_M_root() = 0;
_M_leftmost() = _M_end();
_M_rightmost() = _M_end();
*************** namespace std
*** 583,605 ****
// Accessors.
_Compare
key_comp() const
! { return _M_impl._M_key_compare(); }
iterator
begin()
! { return static_cast<_Link_type>(this->_M_impl._M_header._M_left); }
const_iterator
begin() const
! { return static_cast<_Const_Link_type>(this->_M_impl._M_header._M_left); }
iterator
end()
! { return static_cast<_Link_type>(&this->_M_impl._M_header); }
const_iterator
end() const
! { return static_cast<_Const_Link_type>(&this->_M_impl._M_header); }
reverse_iterator
rbegin()
--- 559,581 ----
// Accessors.
_Compare
key_comp() const
! { return _M_key_compare; }
iterator
begin()
! { return static_cast<_Link_type>(this->_M_header._M_left); }
const_iterator
begin() const
! { return static_cast<_Const_Link_type>(this->_M_header._M_left); }
iterator
end()
! { return static_cast<_Link_type>(&this->_M_header); }
const_iterator
end() const
! { return static_cast<_Const_Link_type>(&this->_M_header); }
reverse_iterator
rbegin()
*************** namespace std
*** 619,629 ****
bool
empty() const
! { return _M_impl._M_node_count == 0; }
size_type
size() const
! { return _M_impl._M_node_count; }
size_type
max_size() const
--- 595,605 ----
bool
empty() const
! { return _M_node_count == 0; }
size_type
size() const
! { return _M_node_count; }
size_type
max_size() const
*************** namespace std
*** 672,678 ****
_M_leftmost() = _M_end();
_M_root() = 0;
_M_rightmost() = _M_end();
! _M_impl._M_node_count = 0;
}
// Set operations.
--- 648,654 ----
_M_leftmost() = _M_end();
_M_root() = 0;
_M_rightmost() = _M_end();
! _M_node_count = 0;
}
// Set operations.
*************** namespace std
*** 773,785 ****
{
// Note that _Key may be a constant type.
clear();
! _M_impl._M_key_compare() = __x._M_impl._M_key_compare();
if (__x._M_root() != 0)
{
_M_root() = _M_copy(__x._M_begin(), _M_end());
_M_leftmost() = _S_minimum(_M_root());
_M_rightmost() = _S_maximum(_M_root());
! _M_impl._M_node_count = __x._M_impl._M_node_count;
}
}
return *this;
--- 749,761 ----
{
// Note that _Key may be a constant type.
clear();
! _M_key_compare = __x._M_key_compare;
if (__x._M_root() != 0)
{
_M_root() = _M_copy(__x._M_begin(), _M_end());
_M_leftmost() = _S_minimum(_M_root());
_M_rightmost() = _S_maximum(_M_root());
! _M_node_count = __x._M_node_count;
}
}
return *this;
*************** namespace std
*** 795,804 ****
bool __insert_left;
__insert_left = __x != 0 || __p == _M_end()
! || _M_impl._M_key_compare()(_KeyOfValue()(__v), _S_key(__p));
! _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, this->_M_impl._M_header);
! ++_M_impl._M_node_count;
return iterator(__z);
}
--- 771,780 ----
bool __insert_left;
__insert_left = __x != 0 || __p == _M_end()
! || _M_key_compare(_KeyOfValue()(__v), _S_key(__p));
! _Rb_tree_insert_and_rebalance(__insert_left, __z, __p, this->_M_header);
! ++_M_node_count;
return iterator(__z);
}
*************** namespace std
*** 813,819 ****
while (__x != 0)
{
__y = __x;
! __x = _M_impl._M_key_compare()(_KeyOfValue()(__v), _S_key(__x)) ?
_S_left(__x) : _S_right(__x);
}
return _M_insert(__x, __y, __v);
--- 789,795 ----
while (__x != 0)
{
__y = __x;
! __x = _M_key_compare(_KeyOfValue()(__v), _S_key(__x)) ?
_S_left(__x) : _S_right(__x);
}
return _M_insert(__x, __y, __v);
*************** namespace std
*** 860,867 ****
__t._M_root()->_M_parent = __t._M_end();
}
// No need to swap header's color as it does not change.
! std::swap(this->_M_impl._M_node_count, __t._M_impl._M_node_count);
! std::swap(this->_M_impl._M_key_compare(), __t._M_impl._M_key_compare());
}
template<typename _Key, typename _Val, typename _KeyOfValue,
--- 836,843 ----
__t._M_root()->_M_parent = __t._M_end();
}
// No need to swap header's color as it does not change.
! std::swap(this->_M_node_count, __t._M_node_count);
! std::swap(this->_M_key_compare, __t._M_key_compare);
}
template<typename _Key, typename _Val, typename _KeyOfValue,
*************** namespace std
*** 877,883 ****
while (__x != 0)
{
__y = __x;
! __comp = _M_impl._M_key_compare()(_KeyOfValue()(__v), _S_key(__x));
__x = __comp ? _S_left(__x) : _S_right(__x);
}
iterator __j = iterator(__y);
--- 853,859 ----
while (__x != 0)
{
__y = __x;
! __comp = _M_key_compare(_KeyOfValue()(__v), _S_key(__x));
__x = __comp ? _S_left(__x) : _S_right(__x);
}
iterator __j = iterator(__y);
*************** namespace std
*** 886,892 ****
return pair<iterator,bool>(_M_insert(__x, __y, __v), true);
else
--__j;
! if (_M_impl._M_key_compare()(_S_key(__j._M_node), _KeyOfValue()(__v)))
return pair<iterator,bool>(_M_insert(__x, __y, __v), true);
return pair<iterator,bool>(__j, false);
}
--- 862,868 ----
return pair<iterator,bool>(_M_insert(__x, __y, __v), true);
else
--__j;
! if (_M_key_compare(_S_key(__j._M_node), _KeyOfValue()(__v)))
return pair<iterator,bool>(_M_insert(__x, __y, __v), true);
return pair<iterator,bool>(__j, false);
}
*************** namespace std
*** 901,907 ****
{
// begin()
if (size() > 0
! && _M_impl._M_key_compare()(_KeyOfValue()(__v), _S_key(__position._M_node)))
return _M_insert(__position._M_node, __position._M_node, __v);
// first argument just needs to be non-null
else
--- 877,883 ----
{
// begin()
if (size() > 0
! && _M_key_compare(_KeyOfValue()(__v), _S_key(__position._M_node)))
return _M_insert(__position._M_node, __position._M_node, __v);
// first argument just needs to be non-null
else
*************** namespace std
*** 910,916 ****
else if (__position._M_node == _M_end())
{
// end()
! if (_M_impl._M_key_compare()(_S_key(_M_rightmost()), _KeyOfValue()(__v)))
return _M_insert(0, _M_rightmost(), __v);
else
return insert_unique(__v).first;
--- 886,892 ----
else if (__position._M_node == _M_end())
{
// end()
! if (_M_key_compare(_S_key(_M_rightmost()), _KeyOfValue()(__v)))
return _M_insert(0, _M_rightmost(), __v);
else
return insert_unique(__v).first;
*************** namespace std
*** 919,926 ****
{
iterator __before = __position;
--__before;
! if (_M_impl._M_key_compare()(_S_key(__before._M_node), _KeyOfValue()(__v))
! && _M_impl._M_key_compare()(_KeyOfValue()(__v),_S_key(__position._M_node)))
{
if (_S_right(__before._M_node) == 0)
return _M_insert(0, __before._M_node, __v);
--- 895,902 ----
{
iterator __before = __position;
--__before;
! if (_M_key_compare(_S_key(__before._M_node), _KeyOfValue()(__v))
! && _M_key_compare(_KeyOfValue()(__v),_S_key(__position._M_node)))
{
if (_S_right(__before._M_node) == 0)
return _M_insert(0, __before._M_node, __v);
*************** namespace std
*** 943,949 ****
{
// begin()
if (size() > 0
! && !_M_impl._M_key_compare()(_S_key(__position._M_node),
_KeyOfValue()(__v)))
return _M_insert(__position._M_node, __position._M_node, __v);
// first argument just needs to be non-null
--- 919,925 ----
{
// begin()
if (size() > 0
! && !_M_key_compare(_S_key(__position._M_node),
_KeyOfValue()(__v)))
return _M_insert(__position._M_node, __position._M_node, __v);
// first argument just needs to be non-null
*************** namespace std
*** 953,959 ****
else if (__position._M_node == _M_end())
{
// end()
! if (!_M_impl._M_key_compare()(_KeyOfValue()(__v), _S_key(_M_rightmost())))
return _M_insert(0, _M_rightmost(), __v);
else
return insert_equal(__v);
--- 929,935 ----
else if (__position._M_node == _M_end())
{
// end()
! if (!_M_key_compare(_KeyOfValue()(__v), _S_key(_M_rightmost())))
return _M_insert(0, _M_rightmost(), __v);
else
return insert_equal(__v);
*************** namespace std
*** 962,969 ****
{
iterator __before = __position;
--__before;
! if (!_M_impl._M_key_compare()(_KeyOfValue()(__v), _S_key(__before._M_node))
! && !_M_impl._M_key_compare()(_S_key(__position._M_node),
_KeyOfValue()(__v)))
{
if (_S_right(__before._M_node) == 0)
--- 938,945 ----
{
iterator __before = __position;
--__before;
! if (!_M_key_compare(_KeyOfValue()(__v), _S_key(__before._M_node))
! && !_M_key_compare(_S_key(__position._M_node),
_KeyOfValue()(__v)))
{
if (_S_right(__before._M_node) == 0)
*************** namespace std
*** 1006,1014 ****
{
_Link_type __y =
static_cast<_Link_type>(_Rb_tree_rebalance_for_erase(__position._M_node,
! this->_M_impl._M_header));
destroy_node(__y);
! --_M_impl._M_node_count;
}
template<typename _Key, typename _Val, typename _KeyOfValue,
--- 982,990 ----
{
_Link_type __y =
static_cast<_Link_type>(_Rb_tree_rebalance_for_erase(__position._M_node,
! this->_M_header));
destroy_node(__y);
! --_M_node_count;
}
template<typename _Key, typename _Val, typename _KeyOfValue,
*************** namespace std
*** 1104,1116 ****
_Link_type __y = _M_end(); // Last node which is not less than __k.
while (__x != 0)
! if (!_M_impl._M_key_compare()(_S_key(__x), __k))
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
iterator __j = iterator(__y);
! return (__j == end() || _M_impl._M_key_compare()(__k, _S_key(__j._M_node))) ?
end() : __j;
}
--- 1080,1092 ----
_Link_type __y = _M_end(); // Last node which is not less than __k.
while (__x != 0)
! if (!_M_key_compare(_S_key(__x), __k))
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
iterator __j = iterator(__y);
! return (__j == end() || _M_key_compare(__k, _S_key(__j._M_node))) ?
end() : __j;
}
*************** namespace std
*** 1125,1137 ****
while (__x != 0)
{
! if (!_M_impl._M_key_compare()(_S_key(__x), __k))
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
}
const_iterator __j = const_iterator(__y);
! return (__j == end() || _M_impl._M_key_compare()(__k, _S_key(__j._M_node))) ?
end() : __j;
}
--- 1101,1113 ----
while (__x != 0)
{
! if (!_M_key_compare(_S_key(__x), __k))
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
}
const_iterator __j = const_iterator(__y);
! return (__j == end() || _M_key_compare(__k, _S_key(__j._M_node))) ?
end() : __j;
}
*************** namespace std
*** 1156,1162 ****
_Link_type __y = _M_end(); // Last node which is not less than __k.
while (__x != 0)
! if (!_M_impl._M_key_compare()(_S_key(__x), __k))
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
--- 1132,1138 ----
_Link_type __y = _M_end(); // Last node which is not less than __k.
while (__x != 0)
! if (!_M_key_compare(_S_key(__x), __k))
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
*************** namespace std
*** 1174,1180 ****
_Const_Link_type __y = _M_end(); // Last node which is not less than __k.
while (__x != 0)
! if (!_M_impl._M_key_compare()(_S_key(__x), __k))
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
--- 1150,1156 ----
_Const_Link_type __y = _M_end(); // Last node which is not less than __k.
while (__x != 0)
! if (!_M_key_compare(_S_key(__x), __k))
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
*************** namespace std
*** 1192,1198 ****
_Link_type __y = _M_end(); // Last node which is greater than __k.
while (__x != 0)
! if (_M_impl._M_key_compare()(__k, _S_key(__x)))
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
--- 1168,1174 ----
_Link_type __y = _M_end(); // Last node which is greater than __k.
while (__x != 0)
! if (_M_key_compare(__k, _S_key(__x)))
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
*************** namespace std
*** 1210,1216 ****
_Const_Link_type __y = _M_end(); // Last node which is greater than __k.
while (__x != 0)
! if (_M_impl._M_key_compare()(__k, _S_key(__x)))
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
--- 1186,1192 ----
_Const_Link_type __y = _M_end(); // Last node which is greater than __k.
while (__x != 0)
! if (_M_key_compare(__k, _S_key(__x)))
__y = __x, __x = _S_left(__x);
else
__x = _S_right(__x);
*************** namespace std
*** 1248,1257 ****
bool
_Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const
{
! if (_M_impl._M_node_count == 0 || begin() == end())
! return _M_impl._M_node_count == 0 && begin() == end()
! && this->_M_impl._M_header._M_left == _M_end()
! && this->_M_impl._M_header._M_right == _M_end();
unsigned int __len = _Rb_tree_black_count(_M_leftmost(), _M_root());
for (const_iterator __it = begin(); __it != end(); ++__it)
--- 1224,1233 ----
bool
_Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::__rb_verify() const
{
! if (_M_node_count == 0 || begin() == end())
! return _M_node_count == 0 && begin() == end()
! && this->_M_header._M_left == _M_end()
! && this->_M_header._M_right == _M_end();
unsigned int __len = _Rb_tree_black_count(_M_leftmost(), _M_root());
for (const_iterator __it = begin(); __it != end(); ++__it)
*************** namespace std
*** 1265,1273 ****
|| (__R && __R->_M_color == _S_red))
return false;
! if (__L && _M_impl._M_key_compare()(_S_key(__x), _S_key(__L)))
return false;
! if (__R && _M_impl._M_key_compare()(_S_key(__R), _S_key(__x)))
return false;
if (!__L && !__R && _Rb_tree_black_count(__x, _M_root()) != __len)
--- 1241,1249 ----
|| (__R && __R->_M_color == _S_red))
return false;
! if (__L && _M_key_compare(_S_key(__x), _S_key(__L)))
return false;
! if (__R && _M_key_compare(_S_key(__R), _S_key(__x)))
return false;
if (!__L && !__R && _Rb_tree_black_count(__x, _M_root()) != __len)
diff -Nrcp -x '*cvs*' ./include/bits/stl_vector.h /home/dhruv/projects/cvs_libstdc++-v3/include/bits/stl_vector.h
*** ./include/bits/stl_vector.h 2004-03-25 15:24:21.000000000 +0530
--- /home/dhruv/projects/cvs_libstdc++-v3/include/bits/stl_vector.h 2004-02-08 10:16:42.000000000 +0530
*************** namespace __gnu_norm
*** 74,120 ****
*/
template<typename _Tp, typename _Alloc>
struct _Vector_base
{
- struct _Vector_impl
- : public _Alloc {
- _Tp* _M_start;
- _Tp* _M_finish;
- _Tp* _M_end_of_storage;
- _Vector_impl (_Alloc const& __a)
- : _Alloc(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
- { }
- };
-
public:
typedef _Alloc allocator_type;
allocator_type
! get_allocator() const { return *static_cast<const _Alloc*>(&this->_M_impl); }
! _Vector_base(const allocator_type& __a) : _M_impl(__a)
! { }
_Vector_base(size_t __n, const allocator_type& __a)
! : _M_impl(__a)
{
! this->_M_impl._M_start = this->_M_allocate(__n);
! this->_M_impl._M_finish = this->_M_impl._M_start;
! this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
}
~_Vector_base()
! { _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start); }
public:
! _Vector_impl _M_impl;
_Tp*
! _M_allocate(size_t __n) { return _M_impl.allocate(__n); }
void
_M_deallocate(_Tp* __p, size_t __n)
! { if (__p) _M_impl.deallocate(__p, __n); }
};
--- 74,113 ----
*/
template<typename _Tp, typename _Alloc>
struct _Vector_base
+ : public _Alloc
{
public:
typedef _Alloc allocator_type;
allocator_type
! get_allocator() const { return *static_cast<const _Alloc*>(this); }
! _Vector_base(const allocator_type& __a)
! : _Alloc(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0) { }
_Vector_base(size_t __n, const allocator_type& __a)
! : _Alloc(__a)
{
! this->_M_start = this->_M_allocate(__n);
! this->_M_finish = this->_M_start;
! this->_M_end_of_storage = this->_M_start + __n;
}
~_Vector_base()
! { _M_deallocate(this->_M_start,
! this->_M_end_of_storage - this->_M_start); }
public:
! _Tp* _M_start;
! _Tp* _M_finish;
! _Tp* _M_end_of_storage;
_Tp*
! _M_allocate(size_t __n) { return _Alloc::allocate(__n); }
void
_M_deallocate(_Tp* __p, size_t __n)
! { if (__p) _Alloc::deallocate(__p, __n); }
};
*************** namespace __gnu_norm
*** 169,175 ****
*/
using _Base::_M_allocate;
using _Base::_M_deallocate;
! using _Base::_M_impl;
public:
// [23.2.4.1] construct/copy/destroy
--- 162,170 ----
*/
using _Base::_M_allocate;
using _Base::_M_deallocate;
! using _Base::_M_start;
! using _Base::_M_finish;
! using _Base::_M_end_of_storage;
public:
// [23.2.4.1] construct/copy/destroy
*************** namespace __gnu_norm
*** 191,197 ****
vector(size_type __n, const value_type& __value,
const allocator_type& __a = allocator_type())
: _Base(__n, __a)
! { this->_M_impl._M_finish = std::uninitialized_fill_n(this->_M_impl._M_start,
__n, __value); }
/**
--- 186,192 ----
vector(size_type __n, const value_type& __value,
const allocator_type& __a = allocator_type())
: _Base(__n, __a)
! { this->_M_finish = std::uninitialized_fill_n(this->_M_start,
__n, __value); }
/**
*************** namespace __gnu_norm
*** 204,210 ****
explicit
vector(size_type __n)
: _Base(__n, allocator_type())
! { this->_M_impl._M_finish = std::uninitialized_fill_n(this->_M_impl._M_start,
__n, value_type()); }
/**
--- 199,205 ----
explicit
vector(size_type __n)
: _Base(__n, allocator_type())
! { this->_M_finish = std::uninitialized_fill_n(this->_M_start,
__n, value_type()); }
/**
*************** namespace __gnu_norm
*** 218,225 ****
*/
vector(const vector& __x)
: _Base(__x.size(), __x.get_allocator())
! { this->_M_impl._M_finish = std::uninitialized_copy(__x.begin(), __x.end(),
! this->_M_impl._M_start);
}
/**
--- 213,220 ----
*/
vector(const vector& __x)
: _Base(__x.size(), __x.get_allocator())
! { this->_M_finish = std::uninitialized_copy(__x.begin(), __x.end(),
! this->_M_start);
}
/**
*************** namespace __gnu_norm
*** 253,259 ****
* not touched in any way. Managing the pointer is the user's
* responsibilty.
*/
! ~vector() { std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish); }
/**
* @brief %Vector assignment operator.
--- 248,254 ----
* not touched in any way. Managing the pointer is the user's
* responsibilty.
*/
! ~vector() { std::_Destroy(this->_M_start, this->_M_finish); }
/**
* @brief %Vector assignment operator.
*************** namespace __gnu_norm
*** 311,317 ****
* element order.
*/
iterator
! begin() { return iterator (this->_M_impl._M_start); }
/**
* Returns a read-only (constant) iterator that points to the
--- 306,312 ----
* element order.
*/
iterator
! begin() { return iterator (this->_M_start); }
/**
* Returns a read-only (constant) iterator that points to the
*************** namespace __gnu_norm
*** 319,325 ****
* element order.
*/
const_iterator
! begin() const { return const_iterator (this->_M_impl._M_start); }
/**
* Returns a read/write iterator that points one past the last
--- 314,320 ----
* element order.
*/
const_iterator
! begin() const { return const_iterator (this->_M_start); }
/**
* Returns a read/write iterator that points one past the last
*************** namespace __gnu_norm
*** 327,333 ****
* element order.
*/
iterator
! end() { return iterator (this->_M_impl._M_finish); }
/**
* Returns a read-only (constant) iterator that points one past
--- 322,328 ----
* element order.
*/
iterator
! end() { return iterator (this->_M_finish); }
/**
* Returns a read-only (constant) iterator that points one past
*************** namespace __gnu_norm
*** 335,341 ****
* ordinary element order.
*/
const_iterator
! end() const { return const_iterator (this->_M_impl._M_finish); }
/**
* Returns a read/write reverse iterator that points to the
--- 330,336 ----
* ordinary element order.
*/
const_iterator
! end() const { return const_iterator (this->_M_finish); }
/**
* Returns a read/write reverse iterator that points to the
*************** namespace __gnu_norm
*** 417,423 ****
*/
size_type
capacity() const
! { return size_type(const_iterator(this->_M_impl._M_end_of_storage) - begin()); }
/**
* Returns true if the %vector is empty. (Thus begin() would
--- 412,418 ----
*/
size_type
capacity() const
! { return size_type(const_iterator(this->_M_end_of_storage) - begin()); }
/**
* Returns true if the %vector is empty. (Thus begin() would
*************** namespace __gnu_norm
*** 555,564 ****
void
push_back(const value_type& __x)
{
! if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
{
! std::_Construct(this->_M_impl._M_finish, __x);
! ++this->_M_impl._M_finish;
}
else
_M_insert_aux(end(), __x);
--- 550,559 ----
void
push_back(const value_type& __x)
{
! if (this->_M_finish != this->_M_end_of_storage)
{
! std::_Construct(this->_M_finish, __x);
! ++this->_M_finish;
}
else
_M_insert_aux(end(), __x);
*************** namespace __gnu_norm
*** 576,583 ****
void
pop_back()
{
! --this->_M_impl._M_finish;
! std::_Destroy(this->_M_impl._M_finish);
}
/**
--- 571,578 ----
void
pop_back()
{
! --this->_M_finish;
! std::_Destroy(this->_M_finish);
}
/**
*************** namespace __gnu_norm
*** 686,694 ****
void
swap(vector& __x)
{
! std::swap(this->_M_impl._M_start, __x._M_impl._M_start);
! std::swap(this->_M_impl._M_finish, __x._M_impl._M_finish);
! std::swap(this->_M_impl._M_end_of_storage, __x._M_impl._M_end_of_storage);
}
/**
--- 681,689 ----
void
swap(vector& __x)
{
! std::swap(this->_M_start, __x._M_start);
! std::swap(this->_M_finish, __x._M_finish);
! std::swap(this->_M_end_of_storage, __x._M_end_of_storage);
}
/**
*************** namespace __gnu_norm
*** 733,741 ****
void
_M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
{
! this->_M_impl._M_start = _M_allocate(__n);
! this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
! this->_M_impl._M_finish = std::uninitialized_fill_n(this->_M_impl._M_start,
__n, __value);
}
--- 728,736 ----
void
_M_initialize_dispatch(_Integer __n, _Integer __value, __true_type)
{
! this->_M_start = _M_allocate(__n);
! this->_M_end_of_storage = this->_M_start + __n;
! this->_M_finish = std::uninitialized_fill_n(this->_M_start,
__n, __value);
}
*************** namespace __gnu_norm
*** 767,776 ****
_ForwardIterator __last, forward_iterator_tag)
{
size_type __n = std::distance(__first, __last);
! this->_M_impl._M_start = this->_M_allocate(__n);
! this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
! this->_M_impl._M_finish = std::uninitialized_copy(__first, __last,
! this->_M_impl._M_start);
}
--- 762,771 ----
_ForwardIterator __last, forward_iterator_tag)
{
size_type __n = std::distance(__first, __last);
! this->_M_start = this->_M_allocate(__n);
! this->_M_end_of_storage = this->_M_start + __n;
! this->_M_finish = std::uninitialized_copy(__first, __last,
! this->_M_start);
}
diff -Nrcp -x '*cvs*' ./include/bits/vector.tcc /home/dhruv/projects/cvs_libstdc++-v3/include/bits/vector.tcc
*** ./include/bits/vector.tcc 2004-03-25 15:16:04.000000000 +0530
--- /home/dhruv/projects/cvs_libstdc++-v3/include/bits/vector.tcc 2004-02-08 10:16:42.000000000 +0530
*************** namespace __gnu_norm
*** 74,87 ****
{
const size_type __old_size = size();
pointer __tmp = _M_allocate_and_copy(__n,
! this->_M_impl._M_start,
! this->_M_impl._M_finish);
! std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
! this->_M_impl._M_start = __tmp;
! this->_M_impl._M_finish = __tmp + __old_size;
! this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __n;
}
}
--- 74,87 ----
{
const size_type __old_size = size();
pointer __tmp = _M_allocate_and_copy(__n,
! this->_M_start,
! this->_M_finish);
! std::_Destroy(this->_M_start, this->_M_finish);
! _M_deallocate(this->_M_start,
! this->_M_end_of_storage - this->_M_start);
! this->_M_start = __tmp;
! this->_M_finish = __tmp + __old_size;
! this->_M_end_of_storage = this->_M_start + __n;
}
}
*************** namespace __gnu_norm
*** 91,100 ****
insert(iterator __position, const value_type& __x)
{
size_type __n = __position - begin();
! if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage && __position == end())
{
! std::_Construct(this->_M_impl._M_finish, __x);
! ++this->_M_impl._M_finish;
}
else
_M_insert_aux(__position, __x);
--- 91,100 ----
insert(iterator __position, const value_type& __x)
{
size_type __n = __position - begin();
! if (this->_M_finish != this->_M_end_of_storage && __position == end())
{
! std::_Construct(this->_M_finish, __x);
! ++this->_M_finish;
}
else
_M_insert_aux(__position, __x);
*************** namespace __gnu_norm
*** 108,115 ****
{
if (__position + 1 != end())
std::copy(__position + 1, end(), __position);
! --this->_M_impl._M_finish;
! std::_Destroy(this->_M_impl._M_finish);
return __position;
}
--- 108,115 ----
{
if (__position + 1 != end())
std::copy(__position + 1, end(), __position);
! --this->_M_finish;
! std::_Destroy(this->_M_finish);
return __position;
}
*************** namespace __gnu_norm
*** 120,126 ****
{
iterator __i(copy(__last, end(), __first));
std::_Destroy(__i, end());
! this->_M_impl._M_finish = this->_M_impl._M_finish - (__last - __first);
return __first;
}
--- 120,126 ----
{
iterator __i(copy(__last, end(), __first));
std::_Destroy(__i, end());
! this->_M_finish = this->_M_finish - (__last - __first);
return __first;
}
*************** namespace __gnu_norm
*** 135,145 ****
if (__xlen > capacity())
{
pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end());
! std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
! this->_M_impl._M_start = __tmp;
! this->_M_impl._M_end_of_storage = this->_M_impl._M_start + __xlen;
}
else if (size() >= __xlen)
{
--- 135,145 ----
if (__xlen > capacity())
{
pointer __tmp = _M_allocate_and_copy(__xlen, __x.begin(), __x.end());
! std::_Destroy(this->_M_start, this->_M_finish);
! _M_deallocate(this->_M_start,
! this->_M_end_of_storage - this->_M_start);
! this->_M_start = __tmp;
! this->_M_end_of_storage = this->_M_start + __xlen;
}
else if (size() >= __xlen)
{
*************** namespace __gnu_norm
*** 148,157 ****
}
else
{
! std::copy(__x.begin(), __x.begin() + size(), this->_M_impl._M_start);
! std::uninitialized_copy(__x.begin() + size(), __x.end(), this->_M_impl._M_finish);
}
! this->_M_impl._M_finish = this->_M_impl._M_start + __xlen;
}
return *this;
}
--- 148,157 ----
}
else
{
! std::copy(__x.begin(), __x.begin() + size(), this->_M_start);
! std::uninitialized_copy(__x.begin() + size(), __x.end(), this->_M_finish);
}
! this->_M_finish = this->_M_start + __xlen;
}
return *this;
}
*************** namespace __gnu_norm
*** 169,176 ****
else if (__n > size())
{
std::fill(begin(), end(), __val);
! this->_M_impl._M_finish
! = std::uninitialized_fill_n(this->_M_impl._M_finish, __n - size(), __val);
}
else
erase(fill_n(begin(), __n, __val), end());
--- 169,176 ----
else if (__n > size())
{
std::fill(begin(), end(), __val);
! this->_M_finish
! = std::uninitialized_fill_n(this->_M_finish, __n - size(), __val);
}
else
erase(fill_n(begin(), __n, __val), end());
*************** namespace __gnu_norm
*** 201,224 ****
if (__len > capacity())
{
pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
! std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
! this->_M_impl._M_start = __tmp;
! this->_M_impl._M_end_of_storage = this->_M_impl._M_finish = this->_M_impl._M_start + __len;
}
else if (size() >= __len)
{
! iterator __new_finish(copy(__first, __last, this->_M_impl._M_start));
std::_Destroy(__new_finish, end());
! this->_M_impl._M_finish = __new_finish.base();
}
else
{
_ForwardIterator __mid = __first;
std::advance(__mid, size());
! std::copy(__first, __mid, this->_M_impl._M_start);
! this->_M_impl._M_finish = std::uninitialized_copy(__mid, __last, this->_M_impl._M_finish);
}
}
--- 201,224 ----
if (__len > capacity())
{
pointer __tmp(_M_allocate_and_copy(__len, __first, __last));
! std::_Destroy(this->_M_start, this->_M_finish);
! _M_deallocate(this->_M_start,
! this->_M_end_of_storage - this->_M_start);
! this->_M_start = __tmp;
! this->_M_end_of_storage = this->_M_finish = this->_M_start + __len;
}
else if (size() >= __len)
{
! iterator __new_finish(copy(__first, __last, this->_M_start));
std::_Destroy(__new_finish, end());
! this->_M_finish = __new_finish.base();
}
else
{
_ForwardIterator __mid = __first;
std::advance(__mid, size());
! std::copy(__first, __mid, this->_M_start);
! this->_M_finish = std::uninitialized_copy(__mid, __last, this->_M_finish);
}
}
*************** namespace __gnu_norm
*** 227,240 ****
vector<_Tp,_Alloc>::
_M_insert_aux(iterator __position, const _Tp& __x)
{
! if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
{
! std::_Construct(this->_M_impl._M_finish, *(this->_M_impl._M_finish - 1));
! ++this->_M_impl._M_finish;
_Tp __x_copy = __x;
std::copy_backward(__position,
! iterator(this->_M_impl._M_finish-2),
! iterator(this->_M_impl._M_finish-1));
*__position = __x_copy;
}
else
--- 227,240 ----
vector<_Tp,_Alloc>::
_M_insert_aux(iterator __position, const _Tp& __x)
{
! if (this->_M_finish != this->_M_end_of_storage)
{
! std::_Construct(this->_M_finish, *(this->_M_finish - 1));
! ++this->_M_finish;
_Tp __x_copy = __x;
std::copy_backward(__position,
! iterator(this->_M_finish-2),
! iterator(this->_M_finish-1));
*__position = __x_copy;
}
else
*************** namespace __gnu_norm
*** 245,257 ****
iterator __new_finish(__new_start);
try
{
! __new_finish = std::uninitialized_copy(iterator(this->_M_impl._M_start),
__position,
__new_start);
std::_Construct(__new_finish.base(), __x);
++__new_finish;
__new_finish = std::uninitialized_copy(__position,
! iterator(this->_M_impl._M_finish),
__new_finish);
}
catch(...)
--- 245,257 ----
iterator __new_finish(__new_start);
try
{
! __new_finish = std::uninitialized_copy(iterator(this->_M_start),
__position,
__new_start);
std::_Construct(__new_finish.base(), __x);
++__new_finish;
__new_finish = std::uninitialized_copy(__position,
! iterator(this->_M_finish),
__new_finish);
}
catch(...)
*************** namespace __gnu_norm
*** 261,271 ****
__throw_exception_again;
}
std::_Destroy(begin(), end());
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
! this->_M_impl._M_start = __new_start.base();
! this->_M_impl._M_finish = __new_finish.base();
! this->_M_impl._M_end_of_storage = __new_start.base() + __len;
}
}
--- 261,271 ----
__throw_exception_again;
}
std::_Destroy(begin(), end());
! _M_deallocate(this->_M_start,
! this->_M_end_of_storage - this->_M_start);
! this->_M_start = __new_start.base();
! this->_M_finish = __new_finish.base();
! this->_M_end_of_storage = __new_start.base() + __len;
}
}
*************** namespace __gnu_norm
*** 276,303 ****
{
if (__n != 0)
{
! if (size_type(this->_M_impl._M_end_of_storage - this->_M_impl._M_finish) >= __n)
{
value_type __x_copy = __x;
const size_type __elems_after = end() - __position;
! iterator __old_finish(this->_M_impl._M_finish);
if (__elems_after > __n)
{
! std::uninitialized_copy(this->_M_impl._M_finish - __n,
! this->_M_impl._M_finish,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish += __n;
std::copy_backward(__position, __old_finish - __n, __old_finish);
std::fill(__position, __position + __n, __x_copy);
}
else
{
! std::uninitialized_fill_n(this->_M_impl._M_finish,
__n - __elems_after,
__x_copy);
! this->_M_impl._M_finish += __n - __elems_after;
! std::uninitialized_copy(__position, __old_finish, this->_M_impl._M_finish);
! this->_M_impl._M_finish += __elems_after;
std::fill(__position, __old_finish, __x_copy);
}
}
--- 276,303 ----
{
if (__n != 0)
{
! if (size_type(this->_M_end_of_storage - this->_M_finish) >= __n)
{
value_type __x_copy = __x;
const size_type __elems_after = end() - __position;
! iterator __old_finish(this->_M_finish);
if (__elems_after > __n)
{
! std::uninitialized_copy(this->_M_finish - __n,
! this->_M_finish,
! this->_M_finish);
! this->_M_finish += __n;
std::copy_backward(__position, __old_finish - __n, __old_finish);
std::fill(__position, __position + __n, __x_copy);
}
else
{
! std::uninitialized_fill_n(this->_M_finish,
__n - __elems_after,
__x_copy);
! this->_M_finish += __n - __elems_after;
! std::uninitialized_copy(__position, __old_finish, this->_M_finish);
! this->_M_finish += __elems_after;
std::fill(__position, __old_finish, __x_copy);
}
}
*************** namespace __gnu_norm
*** 321,332 ****
_M_deallocate(__new_start.base(),__len);
__throw_exception_again;
}
! std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
! this->_M_impl._M_start = __new_start.base();
! this->_M_impl._M_finish = __new_finish.base();
! this->_M_impl._M_end_of_storage = __new_start.base() + __len;
}
}
}
--- 321,332 ----
_M_deallocate(__new_start.base(),__len);
__throw_exception_again;
}
! std::_Destroy(this->_M_start, this->_M_finish);
! _M_deallocate(this->_M_start,
! this->_M_end_of_storage - this->_M_start);
! this->_M_start = __new_start.base();
! this->_M_finish = __new_finish.base();
! this->_M_end_of_storage = __new_start.base() + __len;
}
}
}
*************** namespace __gnu_norm
*** 354,369 ****
if (__first != __last)
{
size_type __n = std::distance(__first, __last);
! if (size_type(this->_M_impl._M_end_of_storage - this->_M_impl._M_finish) >= __n)
{
const size_type __elems_after = end() - __position;
! iterator __old_finish(this->_M_impl._M_finish);
if (__elems_after > __n)
{
! std::uninitialized_copy(this->_M_impl._M_finish - __n,
! this->_M_impl._M_finish,
! this->_M_impl._M_finish);
! this->_M_impl._M_finish += __n;
std::copy_backward(__position, __old_finish - __n, __old_finish);
std::copy(__first, __last, __position);
}
--- 354,369 ----
if (__first != __last)
{
size_type __n = std::distance(__first, __last);
! if (size_type(this->_M_end_of_storage - this->_M_finish) >= __n)
{
const size_type __elems_after = end() - __position;
! iterator __old_finish(this->_M_finish);
if (__elems_after > __n)
{
! std::uninitialized_copy(this->_M_finish - __n,
! this->_M_finish,
! this->_M_finish);
! this->_M_finish += __n;
std::copy_backward(__position, __old_finish - __n, __old_finish);
std::copy(__first, __last, __position);
}
*************** namespace __gnu_norm
*** 371,380 ****
{
_ForwardIterator __mid = __first;
std::advance(__mid, __elems_after);
! std::uninitialized_copy(__mid, __last, this->_M_impl._M_finish);
! this->_M_impl._M_finish += __n - __elems_after;
! std::uninitialized_copy(__position, __old_finish, this->_M_impl._M_finish);
! this->_M_impl._M_finish += __elems_after;
std::copy(__first, __mid, __position);
}
}
--- 371,380 ----
{
_ForwardIterator __mid = __first;
std::advance(__mid, __elems_after);
! std::uninitialized_copy(__mid, __last, this->_M_finish);
! this->_M_finish += __n - __elems_after;
! std::uninitialized_copy(__position, __old_finish, this->_M_finish);
! this->_M_finish += __elems_after;
std::copy(__first, __mid, __position);
}
}
*************** namespace __gnu_norm
*** 386,397 ****
iterator __new_finish(__new_start);
try
{
! __new_finish = std::uninitialized_copy(iterator(this->_M_impl._M_start),
__position, __new_start);
__new_finish = std::uninitialized_copy(__first, __last,
__new_finish);
__new_finish = std::uninitialized_copy(__position,
! iterator(this->_M_impl._M_finish),
__new_finish);
}
catch(...)
--- 386,397 ----
iterator __new_finish(__new_start);
try
{
! __new_finish = std::uninitialized_copy(iterator(this->_M_start),
__position, __new_start);
__new_finish = std::uninitialized_copy(__first, __last,
__new_finish);
__new_finish = std::uninitialized_copy(__position,
! iterator(this->_M_finish),
__new_finish);
}
catch(...)
*************** namespace __gnu_norm
*** 400,411 ****
_M_deallocate(__new_start.base(), __len);
__throw_exception_again;
}
! std::_Destroy(this->_M_impl._M_start, this->_M_impl._M_finish);
! _M_deallocate(this->_M_impl._M_start,
! this->_M_impl._M_end_of_storage - this->_M_impl._M_start);
! this->_M_impl._M_start = __new_start.base();
! this->_M_impl._M_finish = __new_finish.base();
! this->_M_impl._M_end_of_storage = __new_start.base() + __len;
}
}
}
--- 400,411 ----
_M_deallocate(__new_start.base(), __len);
__throw_exception_again;
}
! std::_Destroy(this->_M_start, this->_M_finish);
! _M_deallocate(this->_M_start,
! this->_M_end_of_storage - this->_M_start);
! this->_M_start = __new_start.base();
! this->_M_finish = __new_finish.base();
! this->_M_end_of_storage = __new_start.base() + __len;
}
}
}
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |