Commit 0d8c9baf by Paolo Carlini Committed by Paolo Carlini

deque.tcc: Trivial formatting fixes.

2004-04-21  Paolo Carlini  <pcarlini@suse.de>

	* include/bits/deque.tcc: Trivial formatting fixes.
	* include/bits/stl_deque.h: Likewise.
	* include/bits/stl_list.h: Likewise.
	* include/bits/stl_tree.h: Likewise.

From-SVN: r80960
parent 6e90ed19
2004-04-21 Paolo Carlini <pcarlini@suse.de> 2004-04-21 Paolo Carlini <pcarlini@suse.de>
* include/bits/deque.tcc: Trivial formatting fixes.
* include/bits/stl_deque.h: Likewise.
* include/bits/stl_list.h: Likewise.
* include/bits/stl_tree.h: Likewise.
2004-04-21 Paolo Carlini <pcarlini@suse.de>
Andrew Pinski <pinskia@physics.uc.edu> Andrew Pinski <pinskia@physics.uc.edu>
* include/bits/basic_string.tcc (_M_mutate): Don't compute * include/bits/basic_string.tcc (_M_mutate): Don't compute
......
...@@ -131,7 +131,8 @@ namespace _GLIBCXX_STD ...@@ -131,7 +131,8 @@ namespace _GLIBCXX_STD
deque<_Tp,_Alloc>:: deque<_Tp,_Alloc>::
erase(iterator __first, iterator __last) erase(iterator __first, iterator __last)
{ {
if (__first == this->_M_impl._M_start && __last == this->_M_impl._M_finish) if (__first == this->_M_impl._M_start
&& __last == this->_M_impl._M_finish)
{ {
clear(); clear();
return this->_M_impl._M_finish; return this->_M_impl._M_finish;
...@@ -139,13 +140,15 @@ namespace _GLIBCXX_STD ...@@ -139,13 +140,15 @@ namespace _GLIBCXX_STD
else else
{ {
const difference_type __n = __last - __first; const difference_type __n = __last - __first;
const difference_type __elems_before = __first - this->_M_impl._M_start; const difference_type __elems_before = (__first
- this->_M_impl._M_start);
if (static_cast<size_type>(__elems_before) < (size() - __n) / 2) if (static_cast<size_type>(__elems_before) < (size() - __n) / 2)
{ {
std::copy_backward(this->_M_impl._M_start, __first, __last); std::copy_backward(this->_M_impl._M_start, __first, __last);
iterator __new_start = this->_M_impl._M_start + __n; iterator __new_start = this->_M_impl._M_start + __n;
std::_Destroy(this->_M_impl._M_start, __new_start); std::_Destroy(this->_M_impl._M_start, __new_start);
_M_destroy_nodes(this->_M_impl._M_start._M_node, __new_start._M_node); _M_destroy_nodes(this->_M_impl._M_start._M_node,
__new_start._M_node);
this->_M_impl._M_start = __new_start; this->_M_impl._M_start = __new_start;
} }
else else
...@@ -176,12 +179,15 @@ namespace _GLIBCXX_STD ...@@ -176,12 +179,15 @@ namespace _GLIBCXX_STD
if (this->_M_impl._M_start._M_node != this->_M_impl._M_finish._M_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_start._M_cur,
std::_Destroy(this->_M_impl._M_finish._M_first, this->_M_impl._M_finish._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); _M_deallocate_node(this->_M_impl._M_finish._M_first);
} }
else else
std::_Destroy(this->_M_impl._M_start._M_cur, this->_M_impl._M_finish._M_cur); 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; this->_M_impl._M_finish = this->_M_impl._M_start;
} }
...@@ -217,7 +223,8 @@ namespace _GLIBCXX_STD ...@@ -217,7 +223,8 @@ namespace _GLIBCXX_STD
} }
catch(...) catch(...)
{ {
_M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node); _M_destroy_nodes(__new_start._M_node,
this->_M_impl._M_start._M_node);
__throw_exception_again; __throw_exception_again;
} }
} }
...@@ -226,7 +233,8 @@ namespace _GLIBCXX_STD ...@@ -226,7 +233,8 @@ namespace _GLIBCXX_STD
iterator __new_finish = _M_reserve_elements_at_back(__n); iterator __new_finish = _M_reserve_elements_at_back(__n);
try try
{ {
std::uninitialized_fill(this->_M_impl._M_finish, __new_finish, __x); std::uninitialized_fill(this->_M_impl._M_finish,
__new_finish, __x);
this->_M_impl._M_finish = __new_finish; this->_M_impl._M_finish = __new_finish;
} }
catch(...) catch(...)
...@@ -305,11 +313,13 @@ namespace _GLIBCXX_STD ...@@ -305,11 +313,13 @@ namespace _GLIBCXX_STD
std::uninitialized_copy(__first, __mid, *__cur_node); std::uninitialized_copy(__first, __mid, *__cur_node);
__first = __mid; __first = __mid;
} }
std::uninitialized_copy(__first, __last, this->_M_impl._M_finish._M_first); std::uninitialized_copy(__first, __last,
this->_M_impl._M_finish._M_first);
} }
catch(...) catch(...)
{ {
std::_Destroy(this->_M_impl._M_start, iterator(*__cur_node, __cur_node)); std::_Destroy(this->_M_impl._M_start,
iterator(*__cur_node, __cur_node));
__throw_exception_again; __throw_exception_again;
} }
} }
...@@ -326,7 +336,8 @@ namespace _GLIBCXX_STD ...@@ -326,7 +336,8 @@ namespace _GLIBCXX_STD
try try
{ {
std::_Construct(this->_M_impl._M_finish._M_cur, __t_copy); 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_set_node(this->_M_impl._M_finish._M_node
+ 1);
this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_first; this->_M_impl._M_finish._M_cur = this->_M_impl._M_finish._M_first;
} }
catch(...) catch(...)
...@@ -347,7 +358,8 @@ namespace _GLIBCXX_STD ...@@ -347,7 +358,8 @@ namespace _GLIBCXX_STD
*(this->_M_impl._M_start._M_node - 1) = this->_M_allocate_node(); *(this->_M_impl._M_start._M_node - 1) = this->_M_allocate_node();
try try
{ {
this->_M_impl._M_start._M_set_node(this->_M_impl._M_start._M_node - 1); 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; 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); std::_Construct(this->_M_impl._M_start._M_cur, __t_copy);
} }
...@@ -370,10 +382,11 @@ namespace _GLIBCXX_STD ...@@ -370,10 +382,11 @@ namespace _GLIBCXX_STD
std::_Destroy(this->_M_impl._M_finish._M_cur); 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 // Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_last - 1.
// if the deque has at least one element (a precondition for this member // Note that if the deque has at least one element (a precondition for this
// function), and if _M_impl._M_start._M_cur == _M_impl._M_start._M_last, then the deque // member function), and if
// must have at least two nodes. // _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> template <typename _Tp, typename _Alloc>
void deque<_Tp,_Alloc>:: void deque<_Tp,_Alloc>::
_M_pop_front_aux() _M_pop_front_aux()
...@@ -412,7 +425,8 @@ namespace _GLIBCXX_STD ...@@ -412,7 +425,8 @@ namespace _GLIBCXX_STD
} }
catch(...) catch(...)
{ {
_M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node); _M_destroy_nodes(__new_start._M_node,
this->_M_impl._M_start._M_node);
__throw_exception_again; __throw_exception_again;
} }
} }
...@@ -421,7 +435,8 @@ namespace _GLIBCXX_STD ...@@ -421,7 +435,8 @@ namespace _GLIBCXX_STD
iterator __new_finish = _M_reserve_elements_at_back(__n); iterator __new_finish = _M_reserve_elements_at_back(__n);
try try
{ {
std::uninitialized_copy(__first, __last, this->_M_impl._M_finish); std::uninitialized_copy(__first, __last,
this->_M_impl._M_finish);
this->_M_impl._M_finish = __new_finish; this->_M_impl._M_finish = __new_finish;
} }
catch(...) catch(...)
...@@ -485,7 +500,8 @@ namespace _GLIBCXX_STD ...@@ -485,7 +500,8 @@ namespace _GLIBCXX_STD
{ {
if (__elems_before >= difference_type(__n)) if (__elems_before >= difference_type(__n))
{ {
iterator __start_n = this->_M_impl._M_start + difference_type(__n); iterator __start_n = (this->_M_impl._M_start
+ difference_type(__n));
std::uninitialized_copy(this->_M_impl._M_start, __start_n, std::uninitialized_copy(this->_M_impl._M_start, __start_n,
__new_start); __new_start);
this->_M_impl._M_start = __new_start; this->_M_impl._M_start = __new_start;
...@@ -494,16 +510,18 @@ namespace _GLIBCXX_STD ...@@ -494,16 +510,18 @@ namespace _GLIBCXX_STD
} }
else else
{ {
std::__uninitialized_copy_fill(this->_M_impl._M_start, __pos, std::__uninitialized_copy_fill(this->_M_impl._M_start,
__new_start, __pos, __new_start,
this->_M_impl._M_start, __x_copy); this->_M_impl._M_start,
__x_copy);
this->_M_impl._M_start = __new_start; this->_M_impl._M_start = __new_start;
std::fill(__old_start, __pos, __x_copy); std::fill(__old_start, __pos, __x_copy);
} }
} }
catch(...) catch(...)
{ {
_M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node); _M_destroy_nodes(__new_start._M_node,
this->_M_impl._M_start._M_node);
__throw_exception_again; __throw_exception_again;
} }
} }
...@@ -518,7 +536,8 @@ namespace _GLIBCXX_STD ...@@ -518,7 +536,8 @@ namespace _GLIBCXX_STD
{ {
if (__elems_after > difference_type(__n)) if (__elems_after > difference_type(__n))
{ {
iterator __finish_n = this->_M_impl._M_finish - difference_type(__n); iterator __finish_n = (this->_M_impl._M_finish
- difference_type(__n));
std::uninitialized_copy(__finish_n, this->_M_impl._M_finish, std::uninitialized_copy(__finish_n, this->_M_impl._M_finish,
this->_M_impl._M_finish); this->_M_impl._M_finish);
this->_M_impl._M_finish = __new_finish; this->_M_impl._M_finish = __new_finish;
...@@ -563,7 +582,8 @@ namespace _GLIBCXX_STD ...@@ -563,7 +582,8 @@ namespace _GLIBCXX_STD
{ {
if (__elemsbefore >= difference_type(__n)) if (__elemsbefore >= difference_type(__n))
{ {
iterator __start_n = this->_M_impl._M_start + difference_type(__n); iterator __start_n = (this->_M_impl._M_start
+ difference_type(__n));
std::uninitialized_copy(this->_M_impl._M_start, __start_n, std::uninitialized_copy(this->_M_impl._M_start, __start_n,
__new_start); __new_start);
this->_M_impl._M_start = __new_start; this->_M_impl._M_start = __new_start;
...@@ -574,15 +594,17 @@ namespace _GLIBCXX_STD ...@@ -574,15 +594,17 @@ namespace _GLIBCXX_STD
{ {
_ForwardIterator __mid = __first; _ForwardIterator __mid = __first;
std::advance(__mid, difference_type(__n) - __elemsbefore); std::advance(__mid, difference_type(__n) - __elemsbefore);
std::__uninitialized_copy_copy(this->_M_impl._M_start, __pos, std::__uninitialized_copy_copy(this->_M_impl._M_start,
__first, __mid, __new_start); __pos, __first, __mid,
__new_start);
this->_M_impl._M_start = __new_start; this->_M_impl._M_start = __new_start;
std::copy(__mid, __last, __old_start); std::copy(__mid, __last, __old_start);
} }
} }
catch(...) catch(...)
{ {
_M_destroy_nodes(__new_start._M_node, this->_M_impl._M_start._M_node); _M_destroy_nodes(__new_start._M_node,
this->_M_impl._M_start._M_node);
__throw_exception_again; __throw_exception_again;
} }
} }
...@@ -597,7 +619,8 @@ namespace _GLIBCXX_STD ...@@ -597,7 +619,8 @@ namespace _GLIBCXX_STD
{ {
if (__elemsafter > difference_type(__n)) if (__elemsafter > difference_type(__n))
{ {
iterator __finish_n = this->_M_impl._M_finish - difference_type(__n); iterator __finish_n = (this->_M_impl._M_finish
- difference_type(__n));
std::uninitialized_copy(__finish_n, std::uninitialized_copy(__finish_n,
this->_M_impl._M_finish, this->_M_impl._M_finish,
this->_M_impl._M_finish); this->_M_impl._M_finish);
......
...@@ -359,15 +359,15 @@ namespace _GLIBCXX_STD ...@@ -359,15 +359,15 @@ namespace _GLIBCXX_STD
get_allocator() const get_allocator() const
{ return *static_cast<const _Alloc*>(&this->_M_impl); } { return *static_cast<const _Alloc*>(&this->_M_impl); }
typedef _Deque_iterator<_Tp,_Tp&,_Tp*> iterator; typedef _Deque_iterator<_Tp, _Tp&, _Tp*> iterator;
typedef _Deque_iterator<_Tp,const _Tp&,const _Tp*> const_iterator; typedef _Deque_iterator<_Tp, const _Tp&, const _Tp*> const_iterator;
_Deque_base(const allocator_type& __a, size_t __num_elements) _Deque_base(const allocator_type& __a, size_t __num_elements)
: _M_impl(__a) : _M_impl(__a)
{ _M_initialize_map(__num_elements); } { _M_initialize_map(__num_elements); }
_Deque_base(const allocator_type& __a) _Deque_base(const allocator_type& __a)
: _M_impl(__a) : _M_impl(__a)
{ } { }
~_Deque_base(); ~_Deque_base();
...@@ -377,14 +377,15 @@ namespace _GLIBCXX_STD ...@@ -377,14 +377,15 @@ namespace _GLIBCXX_STD
//standard container and at the same time makes use of the EBO //standard container and at the same time makes use of the EBO
//for empty allocators. //for empty allocators.
struct _Deque_impl struct _Deque_impl
: public _Alloc { : public _Alloc
{
_Tp** _M_map; _Tp** _M_map;
size_t _M_map_size; size_t _M_map_size;
iterator _M_start; iterator _M_start;
iterator _M_finish; iterator _M_finish;
_Deque_impl(const _Alloc& __a) _Deque_impl(const _Alloc& __a)
: _Alloc(__a), _M_map(0), _M_map_size(0), _M_start(), _M_finish() : _Alloc(__a), _M_map(0), _M_map_size(0), _M_start(), _M_finish()
{ } { }
}; };
...@@ -422,7 +423,8 @@ namespace _GLIBCXX_STD ...@@ -422,7 +423,8 @@ namespace _GLIBCXX_STD
{ {
if (this->_M_impl._M_map) 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_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); _M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size);
} }
} }
...@@ -452,7 +454,8 @@ namespace _GLIBCXX_STD ...@@ -452,7 +454,8 @@ namespace _GLIBCXX_STD
// the beginning of _M_map, but for small maps it may be as far in as // the beginning of _M_map, but for small maps it may be as far in as
// _M_map+3. // _M_map+3.
_Tp** __nstart = this->_M_impl._M_map + (this->_M_impl._M_map_size - __num_nodes) / 2; _Tp** __nstart = (this->_M_impl._M_map
+ (this->_M_impl._M_map_size - __num_nodes) / 2);
_Tp** __nfinish = __nstart + __num_nodes; _Tp** __nfinish = __nstart + __num_nodes;
try try
...@@ -468,8 +471,9 @@ namespace _GLIBCXX_STD ...@@ -468,8 +471,9 @@ namespace _GLIBCXX_STD
this->_M_impl._M_start._M_set_node(__nstart); this->_M_impl._M_start._M_set_node(__nstart);
this->_M_impl._M_finish._M_set_node(__nfinish - 1); 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_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 this->_M_impl._M_finish._M_cur = (this->_M_impl._M_finish._M_first
% __deque_buf_size(sizeof(_Tp)); + __num_elements
% __deque_buf_size(sizeof(_Tp)));
} }
template<typename _Tp, typename _Alloc> template<typename _Tp, typename _Alloc>
...@@ -668,7 +672,8 @@ namespace _GLIBCXX_STD ...@@ -668,7 +672,8 @@ namespace _GLIBCXX_STD
*/ */
deque(const deque& __x) deque(const deque& __x)
: _Base(__x.get_allocator(), __x.size()) : _Base(__x.get_allocator(), __x.size())
{ std::uninitialized_copy(__x.begin(), __x.end(), this->_M_impl._M_start); } { std::uninitialized_copy(__x.begin(), __x.end(),
this->_M_impl._M_start); }
/** /**
* @brief Builds a %deque from a range. * @brief Builds a %deque from a range.
...@@ -1009,7 +1014,8 @@ namespace _GLIBCXX_STD ...@@ -1009,7 +1014,8 @@ namespace _GLIBCXX_STD
void void
push_back(const value_type& __x) push_back(const value_type& __x)
{ {
if (this->_M_impl._M_finish._M_cur != this->_M_impl._M_finish._M_last - 1) 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); std::_Construct(this->_M_impl._M_finish._M_cur, __x);
++this->_M_impl._M_finish._M_cur; ++this->_M_impl._M_finish._M_cur;
...@@ -1029,7 +1035,8 @@ namespace _GLIBCXX_STD ...@@ -1029,7 +1035,8 @@ namespace _GLIBCXX_STD
void void
pop_front() pop_front()
{ {
if (this->_M_impl._M_start._M_cur != this->_M_impl._M_start._M_last - 1) 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); std::_Destroy(this->_M_impl._M_start._M_cur);
++this->_M_impl._M_start._M_cur; ++this->_M_impl._M_start._M_cur;
...@@ -1049,7 +1056,8 @@ namespace _GLIBCXX_STD ...@@ -1049,7 +1056,8 @@ namespace _GLIBCXX_STD
void void
pop_back() pop_back()
{ {
if (this->_M_impl._M_finish._M_cur != this->_M_impl._M_finish._M_first) if (this->_M_impl._M_finish._M_cur
!= this->_M_impl._M_finish._M_first)
{ {
--this->_M_impl._M_finish._M_cur; --this->_M_impl._M_finish._M_cur;
std::_Destroy(this->_M_impl._M_finish._M_cur); std::_Destroy(this->_M_impl._M_finish._M_cur);
...@@ -1418,7 +1426,8 @@ namespace _GLIBCXX_STD ...@@ -1418,7 +1426,8 @@ namespace _GLIBCXX_STD
void void
_M_reserve_map_at_front (size_type __nodes_to_add = 1) _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)) 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); _M_reallocate_map(__nodes_to_add, true);
} }
......
...@@ -295,10 +295,11 @@ namespace _GLIBCXX_STD ...@@ -295,10 +295,11 @@ namespace _GLIBCXX_STD
_Node_Alloc_type; _Node_Alloc_type;
struct _List_impl struct _List_impl
: public _Node_Alloc_type { : public _Node_Alloc_type
{
_List_node_base _M_node; _List_node_base _M_node;
_List_impl (const _Node_Alloc_type& __a) _List_impl (const _Node_Alloc_type& __a)
: _Node_Alloc_type(__a) : _Node_Alloc_type(__a)
{ } { }
}; };
...@@ -317,10 +318,11 @@ namespace _GLIBCXX_STD ...@@ -317,10 +318,11 @@ namespace _GLIBCXX_STD
allocator_type allocator_type
get_allocator() const get_allocator() const
{ return allocator_type(*static_cast<const _Node_Alloc_type*>(&this->_M_impl)); } { return allocator_type(*static_cast<
const _Node_Alloc_type*>(&this->_M_impl)); }
_List_base(const allocator_type& __a) _List_base(const allocator_type& __a)
: _M_impl(__a) : _M_impl(__a)
{ _M_init(); } { _M_init(); }
// This is what actually destroys the list. // This is what actually destroys the list.
......
...@@ -461,7 +461,8 @@ namespace std ...@@ -461,7 +461,8 @@ namespace std
_Const_Link_type _Const_Link_type
_M_begin() const _M_begin() const
{ return static_cast<_Const_Link_type>(this->_M_impl._M_header._M_parent); } { return static_cast<
_Const_Link_type>(this->_M_impl._M_header._M_parent); }
_Link_type _Link_type
_M_end() _M_end()
...@@ -999,9 +1000,9 @@ namespace std ...@@ -999,9 +1000,9 @@ namespace std
inline void inline void
_Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::erase(iterator __position) _Rb_tree<_Key,_Val,_KeyOfValue,_Compare,_Alloc>::erase(iterator __position)
{ {
_Link_type __y = _Link_type __y = static_cast<
static_cast<_Link_type>(_Rb_tree_rebalance_for_erase(__position._M_node, _Link_type>(_Rb_tree_rebalance_for_erase(__position._M_node,
this->_M_impl._M_header)); this->_M_impl._M_header));
destroy_node(__y); destroy_node(__y);
--_M_impl._M_node_count; --_M_impl._M_node_count;
} }
...@@ -1278,4 +1279,3 @@ namespace std ...@@ -1278,4 +1279,3 @@ namespace std
} // namespace std } // namespace std
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment