This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] fill(_Deque_iterator) clean-up
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 09 Aug 2006 11:58:34 +0200
- Subject: [v3] fill(_Deque_iterator) clean-up
Hi,
tested x86-linux, committed to mainline.
Paolo.
/////////////////
2006-08-09 Paolo Carlini <pcarlini@suse.de>
* include/bits/stl_algobase.h (fill(const _Deque_iterator<>&,
const _Deque_iterator<>&, const _Tp&)): Move...
* include/bits/deque.tcc: ... here.
* include/bits/stl_deque.h: Declare.
Index: include/bits/stl_algobase.h
===================================================================
--- include/bits/stl_algobase.h (revision 116015)
+++ include/bits/stl_algobase.h (working copy)
@@ -618,32 +618,6 @@
std::memset(__first, static_cast<unsigned char>(__tmp), __last - __first);
}
- template<typename _Tp, typename _Ref, typename _Ptr>
- struct _Deque_iterator;
-
- // Overload for deque::iterators, exploiting the "segmented-iterator
- // optimization". NB: leave const_iterators alone!
- template<typename _Tp>
- void
- fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
- const _Deque_iterator<_Tp, _Tp&, _Tp*>& __last, const _Tp& __value)
- {
- typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self;
-
- for (typename _Self::_Map_pointer __node = __first._M_node + 1;
- __node < __last._M_node; ++__node)
- std::fill(*__node, *__node + _Self::_S_buffer_size(), __value);
-
- if (__first._M_node != __last._M_node)
- {
- std::fill(__first._M_cur, __first._M_last, __value);
- std::fill(__last._M_first, __last._M_cur, __value);
- }
- else
- std::fill(__first._M_cur, __last._M_cur, __value);
- }
-
-
template<bool>
struct __fill_n
{
Index: include/bits/stl_deque.h
===================================================================
--- include/bits/stl_deque.h (revision 116015)
+++ include/bits/stl_deque.h (working copy)
@@ -350,6 +350,11 @@
operator+(ptrdiff_t __n, const _Deque_iterator<_Tp, _Ref, _Ptr>& __x)
{ return __x + __n; }
+ template<typename _Tp>
+ void
+ fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
+ const _Deque_iterator<_Tp, _Tp&, _Tp*>& __last, const _Tp& __value);
+
/**
* @if maint
* Deque base class. This class provides the unified face for %deque's
Index: include/bits/deque.tcc
===================================================================
--- include/bits/deque.tcc (revision 116015)
+++ include/bits/deque.tcc (working copy)
@@ -744,6 +744,28 @@
this->_M_impl._M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
}
+ // Overload for deque::iterators, exploiting the "segmented-iterator
+ // optimization". NB: leave const_iterators alone!
+ template<typename _Tp>
+ void
+ fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
+ const _Deque_iterator<_Tp, _Tp&, _Tp*>& __last, const _Tp& __value)
+ {
+ typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self;
+
+ for (typename _Self::_Map_pointer __node = __first._M_node + 1;
+ __node < __last._M_node; ++__node)
+ std::fill(*__node, *__node + _Self::_S_buffer_size(), __value);
+
+ if (__first._M_node != __last._M_node)
+ {
+ std::fill(__first._M_cur, __first._M_last, __value);
+ std::fill(__last._M_first, __last._M_cur, __value);
+ }
+ else
+ std::fill(__first._M_cur, __last._M_cur, __value);
+ }
+
_GLIBCXX_END_NESTED_NAMESPACE
#endif