Commit 43da93a7 by Paolo Carlini Committed by Paolo Carlini

basic_string.h: Trivial formatting fixes and/or const-ification of some variables.

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

	* include/bits/basic_string.h: Trivial formatting fixes and/or
	const-ification of some variables.
	* include/bits/deque.tcc: Likewise.
	* include/bits/stl_algobase.h: Likewise.
	* include/bits/stl_bvector.h: Likewise.
	* include/bits/stl_construct.h: Likewise.
	* include/bits/stl_deque.h: Likewise.
	* include/bits/stl_pair.h: Likewise.
	* include/bits/stl_vector.h: Likewise.
	* include/bits/vector.tcc: Likewise.

From-SVN: r84090
parent 1ec7a978
2004-07-04 Paolo Carlini <pcarlini@suse.de> 2004-07-04 Paolo Carlini <pcarlini@suse.de>
* include/bits/basic_string.h: Trivial formatting fixes and/or
const-ification of some variables.
* include/bits/deque.tcc: Likewise.
* include/bits/stl_algobase.h: Likewise.
* include/bits/stl_bvector.h: Likewise.
* include/bits/stl_construct.h: Likewise.
* include/bits/stl_deque.h: Likewise.
* include/bits/stl_pair.h: Likewise.
* include/bits/stl_vector.h: Likewise.
* include/bits/vector.tcc: Likewise.
2004-07-04 Paolo Carlini <pcarlini@suse.de>
* testsuite/25_algorithms/copy/1.cc: Add instantiations for * testsuite/25_algorithms/copy/1.cc: Add instantiations for
systems with no COMDAT or weak support. systems with no COMDAT or weak support.
* testsuite/25_algorithms/copy/2.cc: Likewise. * testsuite/25_algorithms/copy/2.cc: Likewise.
......
...@@ -1294,47 +1294,47 @@ namespace std ...@@ -1294,47 +1294,47 @@ namespace std
// Specializations for the common case of pointer and iterator: // Specializations for the common case of pointer and iterator:
// useful to avoid the overhead of temporary buffering in _M_replace. // useful to avoid the overhead of temporary buffering in _M_replace.
basic_string& basic_string&
replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2) replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
{ {
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
&& __i2 <= _M_iend()); && __i2 <= _M_iend());
__glibcxx_requires_valid_range(__k1, __k2); __glibcxx_requires_valid_range(__k1, __k2);
return this->replace(__i1 - _M_ibegin(), __i2 - __i1, return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1, __k2 - __k1); __k1, __k2 - __k1);
} }
basic_string& basic_string&
replace(iterator __i1, iterator __i2, replace(iterator __i1, iterator __i2,
const _CharT* __k1, const _CharT* __k2) const _CharT* __k1, const _CharT* __k2)
{ {
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
&& __i2 <= _M_iend()); && __i2 <= _M_iend());
__glibcxx_requires_valid_range(__k1, __k2); __glibcxx_requires_valid_range(__k1, __k2);
return this->replace(__i1 - _M_ibegin(), __i2 - __i1, return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1, __k2 - __k1); __k1, __k2 - __k1);
} }
basic_string& basic_string&
replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2) replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
{ {
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
&& __i2 <= _M_iend()); && __i2 <= _M_iend());
__glibcxx_requires_valid_range(__k1, __k2); __glibcxx_requires_valid_range(__k1, __k2);
return this->replace(__i1 - _M_ibegin(), __i2 - __i1, return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1.base(), __k2 - __k1); __k1.base(), __k2 - __k1);
} }
basic_string& basic_string&
replace(iterator __i1, iterator __i2, replace(iterator __i1, iterator __i2,
const_iterator __k1, const_iterator __k2) const_iterator __k1, const_iterator __k2)
{ {
_GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
&& __i2 <= _M_iend()); && __i2 <= _M_iend());
__glibcxx_requires_valid_range(__k1, __k2); __glibcxx_requires_valid_range(__k1, __k2);
return this->replace(__i1 - _M_ibegin(), __i2 - __i1, return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
__k1.base(), __k2 - __k1); __k1.base(), __k2 - __k1);
} }
private: private:
template<class _Integer> template<class _Integer>
basic_string& basic_string&
......
...@@ -86,7 +86,7 @@ namespace _GLIBCXX_STD ...@@ -86,7 +86,7 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
typename deque<_Tp,_Alloc>::iterator typename deque<_Tp,_Alloc>::iterator
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
insert(iterator position, const value_type& __x) insert(iterator position, const value_type& __x)
{ {
if (position._M_cur == this->_M_impl._M_start._M_cur) if (position._M_cur == this->_M_impl._M_start._M_cur)
...@@ -107,12 +107,12 @@ namespace _GLIBCXX_STD ...@@ -107,12 +107,12 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
typename deque<_Tp,_Alloc>::iterator typename deque<_Tp,_Alloc>::iterator
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
erase(iterator __position) erase(iterator __position)
{ {
iterator __next = __position; iterator __next = __position;
++__next; ++__next;
size_type __index = __position - this->_M_impl._M_start; const size_type __index = __position - this->_M_impl._M_start;
if (__index < (size() >> 1)) if (__index < (size() >> 1))
{ {
std::copy_backward(this->_M_impl._M_start, __position, __next); std::copy_backward(this->_M_impl._M_start, __position, __next);
...@@ -128,7 +128,7 @@ namespace _GLIBCXX_STD ...@@ -128,7 +128,7 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
typename deque<_Tp,_Alloc>::iterator typename deque<_Tp,_Alloc>::iterator
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
erase(iterator __first, iterator __last) erase(iterator __first, iterator __last)
{ {
if (__first == this->_M_impl._M_start if (__first == this->_M_impl._M_start
...@@ -166,7 +166,7 @@ namespace _GLIBCXX_STD ...@@ -166,7 +166,7 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
clear() clear()
{ {
for (_Map_pointer __node = this->_M_impl._M_start._M_node + 1; for (_Map_pointer __node = this->_M_impl._M_start._M_node + 1;
...@@ -195,12 +195,12 @@ namespace _GLIBCXX_STD ...@@ -195,12 +195,12 @@ namespace _GLIBCXX_STD
template <typename _Tp, class _Alloc> template <typename _Tp, class _Alloc>
template <typename _InputIterator> template <typename _InputIterator>
void void
deque<_Tp,_Alloc> deque<_Tp, _Alloc>
::_M_assign_aux(_InputIterator __first, _InputIterator __last, ::_M_assign_aux(_InputIterator __first, _InputIterator __last,
input_iterator_tag) input_iterator_tag)
{ {
iterator __cur = begin(); iterator __cur = begin();
for ( ; __first != __last && __cur != end(); ++__cur, ++__first) for (; __first != __last && __cur != end(); ++__cur, ++__first)
*__cur = *__first; *__cur = *__first;
if (__first == __last) if (__first == __last)
erase(__cur, end()); erase(__cur, end());
...@@ -210,7 +210,7 @@ namespace _GLIBCXX_STD ...@@ -210,7 +210,7 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_fill_insert(iterator __pos, size_type __n, const value_type& __x) _M_fill_insert(iterator __pos, size_type __n, const value_type& __x)
{ {
if (__pos._M_cur == this->_M_impl._M_start._M_cur) if (__pos._M_cur == this->_M_impl._M_start._M_cur)
...@@ -250,7 +250,7 @@ namespace _GLIBCXX_STD ...@@ -250,7 +250,7 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_fill_initialize(const value_type& __value) _M_fill_initialize(const value_type& __value)
{ {
_Map_pointer __cur; _Map_pointer __cur;
...@@ -274,14 +274,14 @@ namespace _GLIBCXX_STD ...@@ -274,14 +274,14 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
template <typename _InputIterator> template <typename _InputIterator>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_range_initialize(_InputIterator __first, _InputIterator __last, _M_range_initialize(_InputIterator __first, _InputIterator __last,
input_iterator_tag) input_iterator_tag)
{ {
this->_M_initialize_map(0); this->_M_initialize_map(0);
try try
{ {
for ( ; __first != __last; ++__first) for (; __first != __last; ++__first)
push_back(*__first); push_back(*__first);
} }
catch(...) catch(...)
...@@ -294,7 +294,7 @@ namespace _GLIBCXX_STD ...@@ -294,7 +294,7 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
template <typename _ForwardIterator> template <typename _ForwardIterator>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_range_initialize(_ForwardIterator __first, _ForwardIterator __last, _M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
forward_iterator_tag) forward_iterator_tag)
{ {
...@@ -327,7 +327,7 @@ namespace _GLIBCXX_STD ...@@ -327,7 +327,7 @@ namespace _GLIBCXX_STD
// Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_last - 1. // Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_last - 1.
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_push_back_aux(const value_type& __t) _M_push_back_aux(const value_type& __t)
{ {
value_type __t_copy = __t; value_type __t_copy = __t;
...@@ -350,7 +350,7 @@ namespace _GLIBCXX_STD ...@@ -350,7 +350,7 @@ namespace _GLIBCXX_STD
// Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_first. // Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_first.
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_push_front_aux(const value_type& __t) _M_push_front_aux(const value_type& __t)
{ {
value_type __t_copy = __t; value_type __t_copy = __t;
...@@ -373,7 +373,7 @@ namespace _GLIBCXX_STD ...@@ -373,7 +373,7 @@ namespace _GLIBCXX_STD
// Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_first. // Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_first.
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
void deque<_Tp,_Alloc>:: void deque<_Tp, _Alloc>::
_M_pop_back_aux() _M_pop_back_aux()
{ {
_M_deallocate_node(this->_M_impl._M_finish._M_first); _M_deallocate_node(this->_M_impl._M_finish._M_first);
...@@ -388,7 +388,7 @@ namespace _GLIBCXX_STD ...@@ -388,7 +388,7 @@ namespace _GLIBCXX_STD
// _M_impl._M_start._M_cur == _M_impl._M_start._M_last, // _M_impl._M_start._M_cur == _M_impl._M_start._M_last,
// then the deque must have at least two nodes. // 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()
{ {
std::_Destroy(this->_M_impl._M_start._M_cur); std::_Destroy(this->_M_impl._M_start._M_cur);
...@@ -400,7 +400,7 @@ namespace _GLIBCXX_STD ...@@ -400,7 +400,7 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
template <typename _InputIterator> template <typename _InputIterator>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_range_insert_aux(iterator __pos, _M_range_insert_aux(iterator __pos,
_InputIterator __first, _InputIterator __last, _InputIterator __first, _InputIterator __last,
input_iterator_tag) input_iterator_tag)
...@@ -409,12 +409,12 @@ namespace _GLIBCXX_STD ...@@ -409,12 +409,12 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
template <typename _ForwardIterator> template <typename _ForwardIterator>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_range_insert_aux(iterator __pos, _M_range_insert_aux(iterator __pos,
_ForwardIterator __first, _ForwardIterator __last, _ForwardIterator __first, _ForwardIterator __last,
forward_iterator_tag) forward_iterator_tag)
{ {
size_type __n = std::distance(__first, __last); const size_type __n = std::distance(__first, __last);
if (__pos._M_cur == this->_M_impl._M_start._M_cur) if (__pos._M_cur == this->_M_impl._M_start._M_cur)
{ {
iterator __new_start = _M_reserve_elements_at_front(__n); iterator __new_start = _M_reserve_elements_at_front(__n);
...@@ -452,7 +452,7 @@ namespace _GLIBCXX_STD ...@@ -452,7 +452,7 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
typename deque<_Tp, _Alloc>::iterator typename deque<_Tp, _Alloc>::iterator
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_insert_aux(iterator __pos, const value_type& __x) _M_insert_aux(iterator __pos, const value_type& __x)
{ {
difference_type __index = __pos - this->_M_impl._M_start; difference_type __index = __pos - this->_M_impl._M_start;
...@@ -485,11 +485,11 @@ namespace _GLIBCXX_STD ...@@ -485,11 +485,11 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_insert_aux(iterator __pos, size_type __n, const value_type& __x) _M_insert_aux(iterator __pos, size_type __n, const value_type& __x)
{ {
const difference_type __elems_before = __pos - this->_M_impl._M_start; const difference_type __elems_before = __pos - this->_M_impl._M_start;
size_type __length = this->size(); const size_type __length = this->size();
value_type __x_copy = __x; value_type __x_copy = __x;
if (__elems_before < difference_type(__length / 2)) if (__elems_before < difference_type(__length / 2))
{ {
...@@ -566,13 +566,13 @@ namespace _GLIBCXX_STD ...@@ -566,13 +566,13 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
template <typename _ForwardIterator> template <typename _ForwardIterator>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_insert_aux(iterator __pos, _M_insert_aux(iterator __pos,
_ForwardIterator __first, _ForwardIterator __last, _ForwardIterator __first, _ForwardIterator __last,
size_type __n) size_type __n)
{ {
const difference_type __elemsbefore = __pos - this->_M_impl._M_start; const difference_type __elemsbefore = __pos - this->_M_impl._M_start;
size_type __length = size(); const size_type __length = size();
if (static_cast<size_type>(__elemsbefore) < __length / 2) if (static_cast<size_type>(__elemsbefore) < __length / 2)
{ {
iterator __new_start = _M_reserve_elements_at_front(__n); iterator __new_start = _M_reserve_elements_at_front(__n);
...@@ -650,10 +650,10 @@ namespace _GLIBCXX_STD ...@@ -650,10 +650,10 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_new_elements_at_front(size_type __new_elems) _M_new_elements_at_front(size_type __new_elems)
{ {
size_type __new_nodes const size_type __new_nodes
= (__new_elems + _S_buffer_size() - 1) / _S_buffer_size(); = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
_M_reserve_map_at_front(__new_nodes); _M_reserve_map_at_front(__new_nodes);
size_type __i; size_type __i;
...@@ -672,11 +672,11 @@ namespace _GLIBCXX_STD ...@@ -672,11 +672,11 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_new_elements_at_back(size_type __new_elems) _M_new_elements_at_back(size_type __new_elems)
{ {
size_type __new_nodes const size_type __new_nodes
= (__new_elems + _S_buffer_size() - 1) / _S_buffer_size(); = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
_M_reserve_map_at_back(__new_nodes); _M_reserve_map_at_back(__new_nodes);
size_type __i; size_type __i;
try try
...@@ -694,12 +694,12 @@ namespace _GLIBCXX_STD ...@@ -694,12 +694,12 @@ namespace _GLIBCXX_STD
template <typename _Tp, typename _Alloc> template <typename _Tp, typename _Alloc>
void void
deque<_Tp,_Alloc>:: deque<_Tp, _Alloc>::
_M_reallocate_map(size_type __nodes_to_add, bool __add_at_front) _M_reallocate_map(size_type __nodes_to_add, bool __add_at_front)
{ {
size_type __old_num_nodes const size_type __old_num_nodes
= this->_M_impl._M_finish._M_node - this->_M_impl._M_start._M_node + 1; = 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; const size_type __new_num_nodes = __old_num_nodes + __nodes_to_add;
_Map_pointer __new_nstart; _Map_pointer __new_nstart;
if (this->_M_impl._M_map_size > 2 * __new_num_nodes) if (this->_M_impl._M_map_size > 2 * __new_num_nodes)
......
...@@ -721,8 +721,8 @@ namespace std ...@@ -721,8 +721,8 @@ namespace std
typename iterator_traits<_InputIterator1>::value_type, typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>) typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first1, __last1);
for ( ; __first1 != __last1; ++__first1, ++__first2) for (; __first1 != __last1; ++__first1, ++__first2)
if (!(*__first1 == *__first2)) if (!(*__first1 == *__first2))
return false; return false;
return true; return true;
...@@ -753,7 +753,7 @@ namespace std ...@@ -753,7 +753,7 @@ namespace std
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>) __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first1, __last1);
for ( ; __first1 != __last1; ++__first1, ++__first2) for (; __first1 != __last1; ++__first1, ++__first2)
if (!__binary_pred(*__first1, *__first2)) if (!__binary_pred(*__first1, *__first2))
return false; return false;
return true; return true;
...@@ -788,7 +788,8 @@ namespace std ...@@ -788,7 +788,8 @@ namespace std
__glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2); __glibcxx_requires_valid_range(__first2, __last2);
for (;__first1 != __last1 && __first2 != __last2; ++__first1, ++__first2) for (; __first1 != __last1 && __first2 != __last2;
++__first1, ++__first2)
{ {
if (*__first1 < *__first2) if (*__first1 < *__first2)
return true; return true;
...@@ -823,8 +824,8 @@ namespace std ...@@ -823,8 +824,8 @@ namespace std
__glibcxx_requires_valid_range(__first1, __last1); __glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2); __glibcxx_requires_valid_range(__first2, __last2);
for ( ; __first1 != __last1 && __first2 != __last2 for (; __first1 != __last1 && __first2 != __last2;
; ++__first1, ++__first2) ++__first1, ++__first2)
{ {
if (__comp(*__first1, *__first2)) if (__comp(*__first1, *__first2))
return true; return true;
......
...@@ -323,7 +323,8 @@ namespace _GLIBCXX_STD ...@@ -323,7 +323,8 @@ namespace _GLIBCXX_STD
} }
const_iterator const_iterator
operator+(difference_type __i) const { operator+(difference_type __i) const
{
const_iterator __tmp = *this; const_iterator __tmp = *this;
return __tmp += __i; return __tmp += __i;
} }
......
...@@ -117,7 +117,10 @@ namespace std ...@@ -117,7 +117,10 @@ namespace std
inline void inline void
__destroy_aux(_ForwardIterator __first, _ForwardIterator __last, __destroy_aux(_ForwardIterator __first, _ForwardIterator __last,
__false_type) __false_type)
{ for ( ; __first != __last; ++__first) std::_Destroy(&*__first); } {
for (; __first != __last; ++__first)
std::_Destroy(&*__first);
}
/** /**
* @if maint * @if maint
......
...@@ -419,15 +419,16 @@ namespace _GLIBCXX_STD ...@@ -419,15 +419,16 @@ namespace _GLIBCXX_STD
}; };
template<typename _Tp, typename _Alloc> template<typename _Tp, typename _Alloc>
_Deque_base<_Tp,_Alloc>::~_Deque_base() _Deque_base<_Tp, _Alloc>::
{ ~_Deque_base()
if (this->_M_impl._M_map)
{ {
_M_destroy_nodes(this->_M_impl._M_start._M_node, if (this->_M_impl._M_map)
this->_M_impl._M_finish._M_node + 1); {
_M_deallocate_map(this->_M_impl._M_map, this->_M_impl._M_map_size); _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);
}
} }
}
/** /**
* @if maint * @if maint
...@@ -441,12 +442,14 @@ namespace _GLIBCXX_STD ...@@ -441,12 +442,14 @@ namespace _GLIBCXX_STD
*/ */
template<typename _Tp, typename _Alloc> template<typename _Tp, typename _Alloc>
void void
_Deque_base<_Tp,_Alloc>::_M_initialize_map(size_t __num_elements) _Deque_base<_Tp, _Alloc>::
_M_initialize_map(size_t __num_elements)
{ {
size_t __num_nodes = __num_elements / __deque_buf_size(sizeof(_Tp)) + 1; const 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, this->_M_impl._M_map_size = std::max((size_t) _S_initial_map_size,
size_t(__num_nodes + 2)); size_t(__num_nodes + 2));
this->_M_impl._M_map = _M_allocate_map(this->_M_impl._M_map_size); 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 // For "small" maps (needing less than _M_map_size nodes), allocation
...@@ -478,7 +481,8 @@ namespace _GLIBCXX_STD ...@@ -478,7 +481,8 @@ namespace _GLIBCXX_STD
template<typename _Tp, typename _Alloc> template<typename _Tp, typename _Alloc>
void void
_Deque_base<_Tp,_Alloc>::_M_create_nodes(_Tp** __nstart, _Tp** __nfinish) _Deque_base<_Tp, _Alloc>::
_M_create_nodes(_Tp** __nstart, _Tp** __nfinish)
{ {
_Tp** __cur; _Tp** __cur;
try try
...@@ -495,7 +499,8 @@ namespace _GLIBCXX_STD ...@@ -495,7 +499,8 @@ namespace _GLIBCXX_STD
template<typename _Tp, typename _Alloc> template<typename _Tp, typename _Alloc>
void void
_Deque_base<_Tp,_Alloc>::_M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish) _Deque_base<_Tp, _Alloc>::
_M_destroy_nodes(_Tp** __nstart, _Tp** __nfinish)
{ {
for (_Tp** __n = __nstart; __n < __nfinish; ++__n) for (_Tp** __n = __nstart; __n < __nfinish; ++__n)
_M_deallocate_node(*__n); _M_deallocate_node(*__n);
...@@ -923,7 +928,10 @@ namespace _GLIBCXX_STD ...@@ -923,7 +928,10 @@ namespace _GLIBCXX_STD
*/ */
reference reference
at(size_type __n) at(size_type __n)
{ _M_range_check(__n); return (*this)[__n]; } {
_M_range_check(__n);
return (*this)[__n];
}
/** /**
* @brief Provides access to the data contained in the %deque. * @brief Provides access to the data contained in the %deque.
......
...@@ -141,7 +141,8 @@ namespace std ...@@ -141,7 +141,8 @@ namespace std
// 181. make_pair() unintended behavior // 181. make_pair() unintended behavior
template<class _T1, class _T2> template<class _T1, class _T2>
inline pair<_T1, _T2> inline pair<_T1, _T2>
make_pair(_T1 __x, _T2 __y) { return pair<_T1, _T2>(__x, __y); } make_pair(_T1 __x, _T2 __y)
{ return pair<_T1, _T2>(__x, __y); }
} // namespace std } // namespace std
#endif /* _PAIR_H */ #endif /* _PAIR_H */
...@@ -81,7 +81,7 @@ namespace _GLIBCXX_STD ...@@ -81,7 +81,7 @@ namespace _GLIBCXX_STD
_Tp* _M_start; _Tp* _M_start;
_Tp* _M_finish; _Tp* _M_finish;
_Tp* _M_end_of_storage; _Tp* _M_end_of_storage;
_Vector_impl (_Alloc const& __a) _Vector_impl(_Alloc const& __a)
: _Alloc(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0) : _Alloc(__a), _M_start(0), _M_finish(0), _M_end_of_storage(0)
{ } { }
}; };
...@@ -799,7 +799,7 @@ namespace _GLIBCXX_STD ...@@ -799,7 +799,7 @@ namespace _GLIBCXX_STD
_M_range_initialize(_InputIterator __first, _M_range_initialize(_InputIterator __first,
_InputIterator __last, input_iterator_tag) _InputIterator __last, input_iterator_tag)
{ {
for ( ; __first != __last; ++__first) for (; __first != __last; ++__first)
push_back(*__first); push_back(*__first);
} }
...@@ -809,7 +809,7 @@ namespace _GLIBCXX_STD ...@@ -809,7 +809,7 @@ namespace _GLIBCXX_STD
_M_range_initialize(_ForwardIterator __first, _M_range_initialize(_ForwardIterator __first,
_ForwardIterator __last, forward_iterator_tag) _ForwardIterator __last, forward_iterator_tag)
{ {
size_type __n = std::distance(__first, __last); const size_type __n = std::distance(__first, __last);
this->_M_impl._M_start = this->_M_allocate(__n); 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_end_of_storage = this->_M_impl._M_start + __n;
this->_M_impl._M_finish = std::uninitialized_copy(__first, __last, this->_M_impl._M_finish = std::uninitialized_copy(__first, __last,
......
...@@ -91,7 +91,7 @@ namespace _GLIBCXX_STD ...@@ -91,7 +91,7 @@ namespace _GLIBCXX_STD
vector<_Tp, _Alloc>:: vector<_Tp, _Alloc>::
insert(iterator __position, const value_type& __x) insert(iterator __position, const value_type& __x)
{ {
size_type __n = __position - begin(); const size_type __n = __position - begin();
if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage
&& __position == end()) && __position == end())
{ {
...@@ -193,7 +193,7 @@ namespace _GLIBCXX_STD ...@@ -193,7 +193,7 @@ namespace _GLIBCXX_STD
input_iterator_tag) input_iterator_tag)
{ {
iterator __cur(begin()); iterator __cur(begin());
for ( ; __first != __last && __cur != end(); ++__cur, ++__first) for (; __first != __last && __cur != end(); ++__cur, ++__first)
*__cur = *__first; *__cur = *__first;
if (__first == __last) if (__first == __last)
erase(__cur, end()); erase(__cur, end());
...@@ -204,11 +204,11 @@ namespace _GLIBCXX_STD ...@@ -204,11 +204,11 @@ namespace _GLIBCXX_STD
template<typename _Tp, typename _Alloc> template<typename _Tp, typename _Alloc>
template<typename _ForwardIterator> template<typename _ForwardIterator>
void void
vector<_Tp,_Alloc>:: vector<_Tp, _Alloc>::
_M_assign_aux(_ForwardIterator __first, _ForwardIterator __last, _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
forward_iterator_tag) forward_iterator_tag)
{ {
size_type __len = std::distance(__first, __last); const size_type __len = std::distance(__first, __last);
if (__len > capacity()) if (__len > capacity())
{ {
...@@ -242,7 +242,7 @@ namespace _GLIBCXX_STD ...@@ -242,7 +242,7 @@ namespace _GLIBCXX_STD
template<typename _Tp, typename _Alloc> template<typename _Tp, typename _Alloc>
void void
vector<_Tp,_Alloc>:: vector<_Tp, _Alloc>::
_M_insert_aux(iterator __position, const _Tp& __x) _M_insert_aux(iterator __position, const _Tp& __x)
{ {
if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage) if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
...@@ -293,7 +293,7 @@ namespace _GLIBCXX_STD ...@@ -293,7 +293,7 @@ namespace _GLIBCXX_STD
template<typename _Tp, typename _Alloc> template<typename _Tp, typename _Alloc>
void void
vector<_Tp,_Alloc>:: vector<_Tp, _Alloc>::
_M_fill_insert(iterator __position, size_type __n, const value_type& __x) _M_fill_insert(iterator __position, size_type __n, const value_type& __x)
{ {
if (__n != 0) if (__n != 0)
...@@ -360,11 +360,11 @@ namespace _GLIBCXX_STD ...@@ -360,11 +360,11 @@ namespace _GLIBCXX_STD
template<typename _Tp, typename _Alloc> template<typename _InputIterator> template<typename _Tp, typename _Alloc> template<typename _InputIterator>
void void
vector<_Tp,_Alloc>:: vector<_Tp, _Alloc>::
_M_range_insert(iterator __pos, _InputIterator __first, _M_range_insert(iterator __pos, _InputIterator __first,
_InputIterator __last, input_iterator_tag) _InputIterator __last, input_iterator_tag)
{ {
for ( ; __first != __last; ++__first) for (; __first != __last; ++__first)
{ {
__pos = insert(__pos, *__first); __pos = insert(__pos, *__first);
++__pos; ++__pos;
...@@ -374,13 +374,13 @@ namespace _GLIBCXX_STD ...@@ -374,13 +374,13 @@ namespace _GLIBCXX_STD
template<typename _Tp, typename _Alloc> template<typename _Tp, typename _Alloc>
template<typename _ForwardIterator> template<typename _ForwardIterator>
void void
vector<_Tp,_Alloc>:: vector<_Tp, _Alloc>::
_M_range_insert(iterator __position,_ForwardIterator __first, _M_range_insert(iterator __position,_ForwardIterator __first,
_ForwardIterator __last, forward_iterator_tag) _ForwardIterator __last, forward_iterator_tag)
{ {
if (__first != __last) if (__first != __last)
{ {
size_type __n = std::distance(__first, __last); const size_type __n = std::distance(__first, __last);
if (size_type(this->_M_impl._M_end_of_storage if (size_type(this->_M_impl._M_end_of_storage
- this->_M_impl._M_finish) >= __n) - this->_M_impl._M_finish) >= __n)
{ {
......
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