+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
// Specializations for the common case of pointer and iterator:
// useful to avoid the overhead of temporary buffering in _M_replace.
basic_string&
- replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
- {
- _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
- && __i2 <= _M_iend());
- __glibcxx_requires_valid_range(__k1, __k2);
- return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
- __k1, __k2 - __k1);
- }
+ replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2)
+ {
+ _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
+ && __i2 <= _M_iend());
+ __glibcxx_requires_valid_range(__k1, __k2);
+ return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
+ __k1, __k2 - __k1);
+ }
basic_string&
- replace(iterator __i1, iterator __i2,
- const _CharT* __k1, const _CharT* __k2)
- {
- _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
- && __i2 <= _M_iend());
- __glibcxx_requires_valid_range(__k1, __k2);
- return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
- __k1, __k2 - __k1);
- }
+ replace(iterator __i1, iterator __i2,
+ const _CharT* __k1, const _CharT* __k2)
+ {
+ _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
+ && __i2 <= _M_iend());
+ __glibcxx_requires_valid_range(__k1, __k2);
+ return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
+ __k1, __k2 - __k1);
+ }
basic_string&
- replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
- {
- _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
- && __i2 <= _M_iend());
- __glibcxx_requires_valid_range(__k1, __k2);
- return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
- __k1.base(), __k2 - __k1);
- }
+ replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2)
+ {
+ _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
+ && __i2 <= _M_iend());
+ __glibcxx_requires_valid_range(__k1, __k2);
+ return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
+ __k1.base(), __k2 - __k1);
+ }
basic_string&
- replace(iterator __i1, iterator __i2,
- const_iterator __k1, const_iterator __k2)
- {
- _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
- && __i2 <= _M_iend());
- __glibcxx_requires_valid_range(__k1, __k2);
- return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
- __k1.base(), __k2 - __k1);
- }
-
+ replace(iterator __i1, iterator __i2,
+ const_iterator __k1, const_iterator __k2)
+ {
+ _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2
+ && __i2 <= _M_iend());
+ __glibcxx_requires_valid_range(__k1, __k2);
+ return this->replace(__i1 - _M_ibegin(), __i2 - __i1,
+ __k1.base(), __k2 - __k1);
+ }
+
private:
template<class _Integer>
basic_string&
template <typename _Tp, typename _Alloc>
typename deque<_Tp,_Alloc>::iterator
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
insert(iterator position, const value_type& __x)
{
if (position._M_cur == this->_M_impl._M_start._M_cur)
template <typename _Tp, typename _Alloc>
typename deque<_Tp,_Alloc>::iterator
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
erase(iterator __position)
{
iterator __next = __position;
++__next;
- size_type __index = __position - this->_M_impl._M_start;
+ const size_type __index = __position - this->_M_impl._M_start;
if (__index < (size() >> 1))
{
std::copy_backward(this->_M_impl._M_start, __position, __next);
template <typename _Tp, typename _Alloc>
typename deque<_Tp,_Alloc>::iterator
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
erase(iterator __first, iterator __last)
{
if (__first == this->_M_impl._M_start
template <typename _Tp, typename _Alloc>
void
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
clear()
{
for (_Map_pointer __node = this->_M_impl._M_start._M_node + 1;
template <typename _Tp, class _Alloc>
template <typename _InputIterator>
void
- deque<_Tp,_Alloc>
+ deque<_Tp, _Alloc>
::_M_assign_aux(_InputIterator __first, _InputIterator __last,
input_iterator_tag)
{
iterator __cur = begin();
- for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
+ for (; __first != __last && __cur != end(); ++__cur, ++__first)
*__cur = *__first;
if (__first == __last)
erase(__cur, end());
template <typename _Tp, typename _Alloc>
void
- deque<_Tp,_Alloc>::
+ 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)
template <typename _Tp, typename _Alloc>
void
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
_M_fill_initialize(const value_type& __value)
{
_Map_pointer __cur;
template <typename _Tp, typename _Alloc>
template <typename _InputIterator>
void
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
_M_range_initialize(_InputIterator __first, _InputIterator __last,
input_iterator_tag)
{
this->_M_initialize_map(0);
try
{
- for ( ; __first != __last; ++__first)
+ for (; __first != __last; ++__first)
push_back(*__first);
}
catch(...)
template <typename _Tp, typename _Alloc>
template <typename _ForwardIterator>
void
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
_M_range_initialize(_ForwardIterator __first, _ForwardIterator __last,
forward_iterator_tag)
{
// 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>::
+ deque<_Tp, _Alloc>::
_M_push_back_aux(const value_type& __t)
{
value_type __t_copy = __t;
// Called only if _M_impl._M_start._M_cur == _M_impl._M_start._M_first.
template <typename _Tp, typename _Alloc>
void
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
_M_push_front_aux(const value_type& __t)
{
value_type __t_copy = __t;
// Called only if _M_impl._M_finish._M_cur == _M_impl._M_finish._M_first.
template <typename _Tp, typename _Alloc>
- void deque<_Tp,_Alloc>::
+ void deque<_Tp, _Alloc>::
_M_pop_back_aux()
{
_M_deallocate_node(this->_M_impl._M_finish._M_first);
// _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>::
+ void deque<_Tp, _Alloc>::
_M_pop_front_aux()
{
std::_Destroy(this->_M_impl._M_start._M_cur);
template <typename _Tp, typename _Alloc>
template <typename _InputIterator>
void
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
_M_range_insert_aux(iterator __pos,
_InputIterator __first, _InputIterator __last,
input_iterator_tag)
template <typename _Tp, typename _Alloc>
template <typename _ForwardIterator>
void
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
_M_range_insert_aux(iterator __pos,
_ForwardIterator __first, _ForwardIterator __last,
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)
{
iterator __new_start = _M_reserve_elements_at_front(__n);
template <typename _Tp, typename _Alloc>
typename deque<_Tp, _Alloc>::iterator
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
_M_insert_aux(iterator __pos, const value_type& __x)
{
difference_type __index = __pos - this->_M_impl._M_start;
template <typename _Tp, typename _Alloc>
void
- deque<_Tp,_Alloc>::
+ 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();
+ const size_type __length = this->size();
value_type __x_copy = __x;
if (__elems_before < difference_type(__length / 2))
{
template <typename _Tp, typename _Alloc>
template <typename _ForwardIterator>
void
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
_M_insert_aux(iterator __pos,
_ForwardIterator __first, _ForwardIterator __last,
size_type __n)
{
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)
{
iterator __new_start = _M_reserve_elements_at_front(__n);
template <typename _Tp, typename _Alloc>
void
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
_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();
_M_reserve_map_at_front(__new_nodes);
size_type __i;
template <typename _Tp, typename _Alloc>
void
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
_M_new_elements_at_back(size_type __new_elems)
{
- size_type __new_nodes
- = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
+ const size_type __new_nodes
+ = (__new_elems + _S_buffer_size() - 1) / _S_buffer_size();
_M_reserve_map_at_back(__new_nodes);
size_type __i;
try
template <typename _Tp, typename _Alloc>
void
- deque<_Tp,_Alloc>::
+ deque<_Tp, _Alloc>::
_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;
- 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;
if (this->_M_impl._M_map_size > 2 * __new_num_nodes)
typename iterator_traits<_InputIterator1>::value_type,
typename iterator_traits<_InputIterator2>::value_type>)
__glibcxx_requires_valid_range(__first1, __last1);
-
- for ( ; __first1 != __last1; ++__first1, ++__first2)
+
+ for (; __first1 != __last1; ++__first1, ++__first2)
if (!(*__first1 == *__first2))
return false;
return true;
__glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
__glibcxx_requires_valid_range(__first1, __last1);
- for ( ; __first1 != __last1; ++__first1, ++__first2)
+ for (; __first1 != __last1; ++__first1, ++__first2)
if (!__binary_pred(*__first1, *__first2))
return false;
return true;
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
- for (;__first1 != __last1 && __first2 != __last2; ++__first1, ++__first2)
+ for (; __first1 != __last1 && __first2 != __last2;
+ ++__first1, ++__first2)
{
if (*__first1 < *__first2)
return true;
__glibcxx_requires_valid_range(__first1, __last1);
__glibcxx_requires_valid_range(__first2, __last2);
- for ( ; __first1 != __last1 && __first2 != __last2
- ; ++__first1, ++__first2)
+ for (; __first1 != __last1 && __first2 != __last2;
+ ++__first1, ++__first2)
{
if (__comp(*__first1, *__first2))
return true;
}
const_iterator
- operator+(difference_type __i) const {
+ operator+(difference_type __i) const
+ {
const_iterator __tmp = *this;
return __tmp += __i;
}
inline void
__destroy_aux(_ForwardIterator __first, _ForwardIterator __last,
__false_type)
- { for ( ; __first != __last; ++__first) std::_Destroy(&*__first); }
+ {
+ for (; __first != __last; ++__first)
+ std::_Destroy(&*__first);
+ }
/**
* @if maint
};
template<typename _Tp, typename _Alloc>
- _Deque_base<_Tp,_Alloc>::~_Deque_base()
- {
- if (this->_M_impl._M_map)
+ _Deque_base<_Tp, _Alloc>::
+ ~_Deque_base()
{
- _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 (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);
+ }
}
- }
/**
* @if maint
*/
template<typename _Tp, typename _Alloc>
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,
- size_t(__num_nodes + 2));
+ size_t(__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
template<typename _Tp, typename _Alloc>
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;
try
template<typename _Tp, typename _Alloc>
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)
_M_deallocate_node(*__n);
*/
reference
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.
// 181. make_pair() unintended behavior
template<class _T1, class _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
#endif /* _PAIR_H */
_Tp* _M_start;
_Tp* _M_finish;
_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)
{ }
};
_M_range_initialize(_InputIterator __first,
_InputIterator __last, input_iterator_tag)
{
- for ( ; __first != __last; ++__first)
+ for (; __first != __last; ++__first)
push_back(*__first);
}
_M_range_initialize(_ForwardIterator __first,
_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_end_of_storage = this->_M_impl._M_start + __n;
this->_M_impl._M_finish = std::uninitialized_copy(__first, __last,
vector<_Tp, _Alloc>::
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
&& __position == end())
{
input_iterator_tag)
{
iterator __cur(begin());
- for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
+ for (; __first != __last && __cur != end(); ++__cur, ++__first)
*__cur = *__first;
if (__first == __last)
erase(__cur, end());
template<typename _Tp, typename _Alloc>
template<typename _ForwardIterator>
void
- vector<_Tp,_Alloc>::
+ vector<_Tp, _Alloc>::
_M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
forward_iterator_tag)
{
- size_type __len = std::distance(__first, __last);
+ const size_type __len = std::distance(__first, __last);
if (__len > capacity())
{
template<typename _Tp, typename _Alloc>
void
- vector<_Tp,_Alloc>::
+ vector<_Tp, _Alloc>::
_M_insert_aux(iterator __position, const _Tp& __x)
{
if (this->_M_impl._M_finish != this->_M_impl._M_end_of_storage)
template<typename _Tp, typename _Alloc>
void
- vector<_Tp,_Alloc>::
+ vector<_Tp, _Alloc>::
_M_fill_insert(iterator __position, size_type __n, const value_type& __x)
{
if (__n != 0)
template<typename _Tp, typename _Alloc> template<typename _InputIterator>
void
- vector<_Tp,_Alloc>::
+ vector<_Tp, _Alloc>::
_M_range_insert(iterator __pos, _InputIterator __first,
_InputIterator __last, input_iterator_tag)
{
- for ( ; __first != __last; ++__first)
+ for (; __first != __last; ++__first)
{
__pos = insert(__pos, *__first);
++__pos;
template<typename _Tp, typename _Alloc>
template<typename _ForwardIterator>
void
- vector<_Tp,_Alloc>::
+ vector<_Tp, _Alloc>::
_M_range_insert(iterator __position,_ForwardIterator __first,
_ForwardIterator __last, forward_iterator_tag)
{
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
- this->_M_impl._M_finish) >= __n)
{