xref: /reactos/sdk/include/c++/stlport/stl/debug/_deque.h (revision c2c66aff)
1*c2c66affSColin Finck /*
2*c2c66affSColin Finck  *
3*c2c66affSColin Finck  * Copyright (c) 1994
4*c2c66affSColin Finck  * Hewlett-Packard Company
5*c2c66affSColin Finck  *
6*c2c66affSColin Finck  * Copyright (c) 1996,1997
7*c2c66affSColin Finck  * Silicon Graphics Computer Systems, Inc.
8*c2c66affSColin Finck  *
9*c2c66affSColin Finck  * Copyright (c) 1997
10*c2c66affSColin Finck  * Moscow Center for SPARC Technology
11*c2c66affSColin Finck  *
12*c2c66affSColin Finck  * Copyright (c) 1999
13*c2c66affSColin Finck  * Boris Fomitchev
14*c2c66affSColin Finck  *
15*c2c66affSColin Finck  * This material is provided "as is", with absolutely no warranty expressed
16*c2c66affSColin Finck  * or implied. Any use is at your own risk.
17*c2c66affSColin Finck  *
18*c2c66affSColin Finck  * Permission to use or copy this software for any purpose is hereby granted
19*c2c66affSColin Finck  * without fee, provided the above notices are retained on all copies.
20*c2c66affSColin Finck  * Permission to modify the code and to distribute modified code is granted,
21*c2c66affSColin Finck  * provided the above notices are retained, and a notice that the code was
22*c2c66affSColin Finck  * modified is included with the above copyright notice.
23*c2c66affSColin Finck  *
24*c2c66affSColin Finck  */
25*c2c66affSColin Finck 
26*c2c66affSColin Finck /* NOTE: This is an internal header file, included by other STL headers.
27*c2c66affSColin Finck  *   You should not attempt to use it directly.
28*c2c66affSColin Finck  */
29*c2c66affSColin Finck 
30*c2c66affSColin Finck #ifndef _STLP_INTERNAL_DBG_DEQUE_H
31*c2c66affSColin Finck #define _STLP_INTERNAL_DBG_DEQUE_H
32*c2c66affSColin Finck 
33*c2c66affSColin Finck #ifndef _STLP_DBG_ITERATOR_H
34*c2c66affSColin Finck #  include <stl/debug/_iterator.h>
35*c2c66affSColin Finck #endif
36*c2c66affSColin Finck 
37*c2c66affSColin Finck #define _STLP_NON_DBG_DEQUE _STLP_PRIV _STLP_NON_DBG_NAME(deque) <_Tp,_Alloc>
38*c2c66affSColin Finck 
39*c2c66affSColin Finck _STLP_BEGIN_NAMESPACE
40*c2c66affSColin Finck 
41*c2c66affSColin Finck #if defined (_STLP_DEBUG_USE_DISTINCT_VALUE_TYPE_HELPERS)
42*c2c66affSColin Finck template <class _Tp, class _Alloc>
value_type(const _STLP_PRIV _DBG_iter_base<_STLP_NON_DBG_DEQUE> &)43*c2c66affSColin Finck inline _Tp* value_type(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_DEQUE >&)
44*c2c66affSColin Finck { return (_Tp*)0; }
45*c2c66affSColin Finck template <class _Tp, class _Alloc>
iterator_category(const _STLP_PRIV _DBG_iter_base<_STLP_NON_DBG_DEQUE> &)46*c2c66affSColin Finck inline random_access_iterator_tag iterator_category(const _STLP_PRIV _DBG_iter_base< _STLP_NON_DBG_DEQUE >&)
47*c2c66affSColin Finck { return random_access_iterator_tag(); }
48*c2c66affSColin Finck #endif
49*c2c66affSColin Finck 
50*c2c66affSColin Finck template <class _Tp, _STLP_DFL_TMPL_PARAM(_Alloc, allocator<_Tp>) >
51*c2c66affSColin Finck class deque :
52*c2c66affSColin Finck #if !defined (__DMC__)
53*c2c66affSColin Finck              private
54*c2c66affSColin Finck #endif
55*c2c66affSColin Finck                      _STLP_PRIV __construct_checker<_STLP_NON_DBG_DEQUE >
56*c2c66affSColin Finck #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND)
57*c2c66affSColin Finck             , public __stlport_class<deque<_Tp, _Alloc> >
58*c2c66affSColin Finck #endif
59*c2c66affSColin Finck {
60*c2c66affSColin Finck   typedef deque<_Tp,_Alloc> _Self;
61*c2c66affSColin Finck   typedef _STLP_NON_DBG_DEQUE _Base;
62*c2c66affSColin Finck   typedef _STLP_PRIV __construct_checker<_STLP_NON_DBG_DEQUE > _ConstructCheck;
63*c2c66affSColin Finck 
64*c2c66affSColin Finck public:
65*c2c66affSColin Finck   // Basic types
66*c2c66affSColin Finck   __IMPORT_CONTAINER_TYPEDEFS(_Base)
67*c2c66affSColin Finck 
68*c2c66affSColin Finck   // Iterators
69*c2c66affSColin Finck   typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Nonconst_traits<value_type> > > iterator;
70*c2c66affSColin Finck   typedef _STLP_PRIV _DBG_iter<_Base, _STLP_PRIV _DbgTraits<_Const_traits<value_type> > >    const_iterator;
71*c2c66affSColin Finck 
72*c2c66affSColin Finck   _STLP_DECLARE_RANDOM_ACCESS_REVERSE_ITERATORS;
73*c2c66affSColin Finck 
74*c2c66affSColin Finck protected:
75*c2c66affSColin Finck   _Base _M_non_dbg_impl;
76*c2c66affSColin Finck   _STLP_PRIV __owned_list _M_iter_list;
77*c2c66affSColin Finck 
_Invalidate_all()78*c2c66affSColin Finck   void _Invalidate_all()
79*c2c66affSColin Finck   { _M_iter_list._Invalidate_all(); }
_Invalidate_iterator(const iterator & __it)80*c2c66affSColin Finck   void _Invalidate_iterator(const iterator& __it)
81*c2c66affSColin Finck   { _STLP_PRIV __invalidate_iterator(&_M_iter_list,__it); }
_Invalidate_iterators(const iterator & __first,const iterator & __last)82*c2c66affSColin Finck   void _Invalidate_iterators(const iterator& __first, const iterator& __last)
83*c2c66affSColin Finck   { _STLP_PRIV __invalidate_range(&_M_iter_list, __first, __last); }
84*c2c66affSColin Finck 
85*c2c66affSColin Finck public:
86*c2c66affSColin Finck   // Basic accessors
get_allocator()87*c2c66affSColin Finck   allocator_type get_allocator() const { return _M_non_dbg_impl.get_allocator(); }
88*c2c66affSColin Finck 
begin()89*c2c66affSColin Finck   iterator begin() { return iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
end()90*c2c66affSColin Finck   iterator end() { return iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
begin()91*c2c66affSColin Finck   const_iterator begin() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.begin()); }
end()92*c2c66affSColin Finck   const_iterator end() const { return const_iterator(&_M_iter_list, _M_non_dbg_impl.end()); }
93*c2c66affSColin Finck 
rbegin()94*c2c66affSColin Finck   reverse_iterator rbegin() { return reverse_iterator(end()); }
rend()95*c2c66affSColin Finck   reverse_iterator rend() { return reverse_iterator(begin()); }
rbegin()96*c2c66affSColin Finck   const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); }
rend()97*c2c66affSColin Finck   const_reverse_iterator rend() const { return const_reverse_iterator(begin()); }
98*c2c66affSColin Finck 
99*c2c66affSColin Finck   reference operator[](size_type __n) {
100*c2c66affSColin Finck     _STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS)
101*c2c66affSColin Finck     return _M_non_dbg_impl[__n];
102*c2c66affSColin Finck   }
103*c2c66affSColin Finck   const_reference operator[](size_type __n) const {
104*c2c66affSColin Finck     _STLP_VERBOSE_ASSERT(__n < size(), _StlMsg_OUT_OF_BOUNDS)
105*c2c66affSColin Finck     return _M_non_dbg_impl[__n];
106*c2c66affSColin Finck   }
107*c2c66affSColin Finck 
at(size_type __n)108*c2c66affSColin Finck   reference at(size_type __n) { return _M_non_dbg_impl.at(__n); }
at(size_type __n)109*c2c66affSColin Finck   const_reference at(size_type __n) const { return _M_non_dbg_impl.at(__n); }
110*c2c66affSColin Finck 
front()111*c2c66affSColin Finck   reference front() {
112*c2c66affSColin Finck     _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
113*c2c66affSColin Finck     return *begin();
114*c2c66affSColin Finck   }
front()115*c2c66affSColin Finck   const_reference front() const {
116*c2c66affSColin Finck     _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
117*c2c66affSColin Finck     return *begin();
118*c2c66affSColin Finck   }
back()119*c2c66affSColin Finck   reference back() {
120*c2c66affSColin Finck     _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
121*c2c66affSColin Finck     return *(--end());
122*c2c66affSColin Finck   }
back()123*c2c66affSColin Finck   const_reference back() const {
124*c2c66affSColin Finck     _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
125*c2c66affSColin Finck     return *(--end());
126*c2c66affSColin Finck   }
127*c2c66affSColin Finck 
128*c2c66affSColin Finck   // Constructor, destructor.
129*c2c66affSColin Finck   explicit deque(const allocator_type& __a = allocator_type()) :
_M_non_dbg_impl(__a)130*c2c66affSColin Finck     _M_non_dbg_impl(__a), _M_iter_list(&_M_non_dbg_impl) {}
deque(const _Self & __x)131*c2c66affSColin Finck   deque(const _Self& __x) :
132*c2c66affSColin Finck     _ConstructCheck(__x), _M_non_dbg_impl(__x._M_non_dbg_impl),
133*c2c66affSColin Finck     _M_iter_list(&_M_non_dbg_impl) {}
134*c2c66affSColin Finck 
135*c2c66affSColin Finck #if !defined(_STLP_DONT_SUP_DFLT_PARAM)
136*c2c66affSColin Finck   explicit deque(size_type __n, const value_type& __x = _Tp(),
137*c2c66affSColin Finck #else
138*c2c66affSColin Finck   deque(size_type __n, const value_type& __x,
139*c2c66affSColin Finck #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
140*c2c66affSColin Finck             const allocator_type& __a = allocator_type()) :
_M_non_dbg_impl(__n,__x,__a)141*c2c66affSColin Finck     _M_non_dbg_impl(__n, __x, __a), _M_iter_list(&_M_non_dbg_impl) {}
142*c2c66affSColin Finck #if defined (_STLP_DONT_SUP_DFLT_PARAM)
deque(size_type __n)143*c2c66affSColin Finck   explicit deque(size_type __n) :
144*c2c66affSColin Finck     _M_non_dbg_impl(__n), _M_iter_list(&_M_non_dbg_impl) {}
145*c2c66affSColin Finck #endif /*_STLP_DONT_SUP_DFLT_PARAM*/
146*c2c66affSColin Finck 
147*c2c66affSColin Finck #if !defined (_STLP_NO_MOVE_SEMANTIC)
deque(__move_source<_Self> src)148*c2c66affSColin Finck   deque(__move_source<_Self> src)
149*c2c66affSColin Finck     : _M_non_dbg_impl(__move_source<_Base>(src.get()._M_non_dbg_impl)),
150*c2c66affSColin Finck       _M_iter_list(&_M_non_dbg_impl) {
151*c2c66affSColin Finck #  if defined (_STLP_NO_EXTENSIONS) || (_STLP_DEBUG_LEVEL == _STLP_STANDARD_DBG_LEVEL)
152*c2c66affSColin Finck     src.get()._M_iter_list._Invalidate_all();
153*c2c66affSColin Finck #  else
154*c2c66affSColin Finck     src.get()._M_iter_list._Set_owner(_M_iter_list);
155*c2c66affSColin Finck #  endif
156*c2c66affSColin Finck   }
157*c2c66affSColin Finck #endif
158*c2c66affSColin Finck 
159*c2c66affSColin Finck #if defined (_STLP_MEMBER_TEMPLATES)
160*c2c66affSColin Finck   template <class _InputIterator>
deque(_InputIterator __first,_InputIterator __last,const allocator_type & __a _STLP_ALLOCATOR_TYPE_DFL)161*c2c66affSColin Finck   deque(_InputIterator __first, _InputIterator __last,
162*c2c66affSColin Finck         const allocator_type& __a _STLP_ALLOCATOR_TYPE_DFL)
163*c2c66affSColin Finck     : _ConstructCheck(__first, __last),
164*c2c66affSColin Finck       _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last), __a),
165*c2c66affSColin Finck       _M_iter_list(&_M_non_dbg_impl) {
166*c2c66affSColin Finck     }
167*c2c66affSColin Finck #  if defined (_STLP_NEEDS_EXTRA_TEMPLATE_CONSTRUCTORS)
168*c2c66affSColin Finck   template <class _InputIterator>
deque(_InputIterator __first,_InputIterator __last)169*c2c66affSColin Finck   deque(_InputIterator __first, _InputIterator __last)
170*c2c66affSColin Finck     : _ConstructCheck(__first, __last),
171*c2c66affSColin Finck       _M_non_dbg_impl(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last)),
172*c2c66affSColin Finck       _M_iter_list(&_M_non_dbg_impl) {
173*c2c66affSColin Finck     }
174*c2c66affSColin Finck #  endif
175*c2c66affSColin Finck #else
176*c2c66affSColin Finck   deque(const value_type* __first, const value_type* __last,
177*c2c66affSColin Finck         const allocator_type& __a = allocator_type())
_ConstructCheck(__first,__last)178*c2c66affSColin Finck     : _ConstructCheck(__first, __last),
179*c2c66affSColin Finck       _M_non_dbg_impl(__first, __last, __a),
180*c2c66affSColin Finck       _M_iter_list(&_M_non_dbg_impl) {
181*c2c66affSColin Finck     }
182*c2c66affSColin Finck 
183*c2c66affSColin Finck   deque(const_iterator __first, const_iterator __last,
184*c2c66affSColin Finck         const allocator_type& __a = allocator_type())
_ConstructCheck(__first,__last)185*c2c66affSColin Finck     : _ConstructCheck(__first, __last),
186*c2c66affSColin Finck       _M_non_dbg_impl(__first._M_iterator, __last._M_iterator, __a),
187*c2c66affSColin Finck       _M_iter_list(&_M_non_dbg_impl) {
188*c2c66affSColin Finck     }
189*c2c66affSColin Finck #endif
190*c2c66affSColin Finck 
191*c2c66affSColin Finck   _Self& operator=(const _Self& __x) {
192*c2c66affSColin Finck     if (this != &__x) {
193*c2c66affSColin Finck       _Invalidate_all();
194*c2c66affSColin Finck       _M_non_dbg_impl = __x._M_non_dbg_impl;
195*c2c66affSColin Finck     }
196*c2c66affSColin Finck     return *this;
197*c2c66affSColin Finck   }
198*c2c66affSColin Finck 
empty()199*c2c66affSColin Finck   bool empty() const { return _M_non_dbg_impl.empty(); }
size()200*c2c66affSColin Finck   size_type size() const { return _M_non_dbg_impl.size(); }
max_size()201*c2c66affSColin Finck   size_type max_size() const { return _M_non_dbg_impl.max_size(); }
202*c2c66affSColin Finck 
swap(_Self & __x)203*c2c66affSColin Finck   void swap(_Self& __x) {
204*c2c66affSColin Finck     _M_iter_list._Swap_owners(__x._M_iter_list);
205*c2c66affSColin Finck     _M_non_dbg_impl.swap(__x._M_non_dbg_impl);
206*c2c66affSColin Finck   }
207*c2c66affSColin Finck #if defined (_STLP_USE_PARTIAL_SPEC_WORKAROUND) && !defined (_STLP_FUNCTION_TMPL_PARTIAL_ORDER)
_M_swap_workaround(_Self & __x)208*c2c66affSColin Finck   void _M_swap_workaround(_Self& __x) { swap(__x); }
209*c2c66affSColin Finck #endif
210*c2c66affSColin Finck 
211*c2c66affSColin Finck public:
assign(size_type __n,const _Tp & __val)212*c2c66affSColin Finck   void assign(size_type __n, const _Tp& __val) {
213*c2c66affSColin Finck     _Invalidate_all();
214*c2c66affSColin Finck     _M_non_dbg_impl.assign(__n, __val);
215*c2c66affSColin Finck   }
216*c2c66affSColin Finck 
217*c2c66affSColin Finck #if defined (_STLP_MEMBER_TEMPLATES)
218*c2c66affSColin Finck   template <class _InputIterator>
assign(_InputIterator __first,_InputIterator __last)219*c2c66affSColin Finck   void assign(_InputIterator __first, _InputIterator __last) {
220*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
221*c2c66affSColin Finck     _Invalidate_all();
222*c2c66affSColin Finck     _M_non_dbg_impl.assign(_STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
223*c2c66affSColin Finck   }
224*c2c66affSColin Finck #else
assign(const_iterator __first,const_iterator __last)225*c2c66affSColin Finck   void assign(const_iterator __first, const_iterator __last) {
226*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
227*c2c66affSColin Finck     _Invalidate_all();
228*c2c66affSColin Finck     _M_non_dbg_impl.assign(__first._M_iterator, __last._M_iterator);
229*c2c66affSColin Finck   }
assign(const value_type * __first,const value_type * __last)230*c2c66affSColin Finck   void assign(const value_type *__first, const value_type *__last) {
231*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
232*c2c66affSColin Finck     _Invalidate_all();
233*c2c66affSColin Finck     _M_non_dbg_impl.assign(__first, __last);
234*c2c66affSColin Finck   }
235*c2c66affSColin Finck #endif
236*c2c66affSColin Finck 
237*c2c66affSColin Finck public:                         // push_* and pop_*
238*c2c66affSColin Finck 
239*c2c66affSColin Finck #if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
240*c2c66affSColin Finck   void push_back(const value_type& __t = _Tp()) {
241*c2c66affSColin Finck #else
242*c2c66affSColin Finck   void push_back(const value_type& __t) {
243*c2c66affSColin Finck #endif
244*c2c66affSColin Finck     _Invalidate_all();
245*c2c66affSColin Finck     _M_non_dbg_impl.push_back(__t);
246*c2c66affSColin Finck   }
247*c2c66affSColin Finck 
248*c2c66affSColin Finck #if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
push_back()249*c2c66affSColin Finck   void push_back() {
250*c2c66affSColin Finck     _Invalidate_all();
251*c2c66affSColin Finck     _M_non_dbg_impl.push_back();
252*c2c66affSColin Finck   }
253*c2c66affSColin Finck #endif
254*c2c66affSColin Finck 
255*c2c66affSColin Finck #if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
256*c2c66affSColin Finck   void push_front(const value_type& __t = _Tp()) {
257*c2c66affSColin Finck #else
258*c2c66affSColin Finck   void push_front(const value_type& __t) {
259*c2c66affSColin Finck #endif
260*c2c66affSColin Finck     _Invalidate_all();
261*c2c66affSColin Finck     _M_non_dbg_impl.push_front(__t);
262*c2c66affSColin Finck   }
263*c2c66affSColin Finck 
264*c2c66affSColin Finck #if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
push_front()265*c2c66affSColin Finck   void push_front() {
266*c2c66affSColin Finck     _Invalidate_all();
267*c2c66affSColin Finck     _M_non_dbg_impl.push_front();
268*c2c66affSColin Finck   }
269*c2c66affSColin Finck #endif
270*c2c66affSColin Finck 
pop_back()271*c2c66affSColin Finck   void pop_back() {
272*c2c66affSColin Finck     _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
273*c2c66affSColin Finck     _Invalidate_iterator(end());
274*c2c66affSColin Finck     _M_non_dbg_impl.pop_back();
275*c2c66affSColin Finck   }
276*c2c66affSColin Finck 
pop_front()277*c2c66affSColin Finck   void pop_front() {
278*c2c66affSColin Finck     _STLP_VERBOSE_ASSERT(!empty(), _StlMsg_EMPTY_CONTAINER)
279*c2c66affSColin Finck     _Invalidate_iterator(begin());
280*c2c66affSColin Finck     _M_non_dbg_impl.pop_front();
281*c2c66affSColin Finck   }
282*c2c66affSColin Finck 
283*c2c66affSColin Finck public:                         // Insert
284*c2c66affSColin Finck 
285*c2c66affSColin Finck #if !defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
286*c2c66affSColin Finck   iterator insert(iterator __pos, const value_type& __x = _Tp()) {
287*c2c66affSColin Finck #else
288*c2c66affSColin Finck   iterator insert(iterator __pos, const value_type& __x) {
289*c2c66affSColin Finck #endif
290*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
291*c2c66affSColin Finck     _Invalidate_all();
292*c2c66affSColin Finck     return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator, __x));
293*c2c66affSColin Finck   }
294*c2c66affSColin Finck 
295*c2c66affSColin Finck #if defined (_STLP_DONT_SUP_DFLT_PARAM) && !defined (_STLP_NO_ANACHRONISMS)
insert(iterator __pos)296*c2c66affSColin Finck   iterator insert(iterator __pos) {
297*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
298*c2c66affSColin Finck     _Invalidate_all();
299*c2c66affSColin Finck     return iterator(&_M_iter_list, _M_non_dbg_impl.insert(__pos._M_iterator));
300*c2c66affSColin Finck   }
301*c2c66affSColin Finck #endif
302*c2c66affSColin Finck 
insert(iterator __pos,size_type __n,const value_type & __x)303*c2c66affSColin Finck   void insert(iterator __pos, size_type __n, const value_type& __x) {
304*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
305*c2c66affSColin Finck     if (__n != 0) _Invalidate_all();
306*c2c66affSColin Finck     _M_non_dbg_impl.insert(__pos._M_iterator, __n, __x);
307*c2c66affSColin Finck   }
308*c2c66affSColin Finck 
309*c2c66affSColin Finck #if defined (_STLP_MEMBER_TEMPLATES)
310*c2c66affSColin Finck   template <class _InputIterator>
insert(iterator __pos,_InputIterator __first,_InputIterator __last)311*c2c66affSColin Finck   void insert(iterator __pos, _InputIterator __first, _InputIterator __last) {
312*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
313*c2c66affSColin Finck     // We perform invalidate first to detect self referencing in __check_range as __first and __last
314*c2c66affSColin Finck     // will have been invalidated.
315*c2c66affSColin Finck     if (__first != __last) _Invalidate_all();
316*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
317*c2c66affSColin Finck     _M_non_dbg_impl.insert(__pos._M_iterator,
318*c2c66affSColin Finck                            _STLP_PRIV _Non_Dbg_iter(__first), _STLP_PRIV _Non_Dbg_iter(__last));
319*c2c66affSColin Finck   }
320*c2c66affSColin Finck #endif
321*c2c66affSColin Finck 
322*c2c66affSColin Finck #if !defined (_STLP_MEMBER_TEMPLATES)
insert(iterator __pos,const value_type * __first,const value_type * __last)323*c2c66affSColin Finck   void insert(iterator __pos,
324*c2c66affSColin Finck               const value_type* __first, const value_type* __last) {
325*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
326*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_ptr_range(__first, __last))
327*c2c66affSColin Finck     if (__first != __last) _Invalidate_all();
328*c2c66affSColin Finck     _M_non_dbg_impl.insert(__pos._M_iterator, __first, __last);
329*c2c66affSColin Finck   }
330*c2c66affSColin Finck #endif
331*c2c66affSColin Finck 
332*c2c66affSColin Finck #if !defined (_STLP_MEMBER_TEMPLATES) || !defined (_STLP_NO_METHOD_SPECIALIZATION)
insert(iterator __pos,const_iterator __first,const_iterator __last)333*c2c66affSColin Finck   void insert(iterator __pos,
334*c2c66affSColin Finck               const_iterator __first, const_iterator __last) {
335*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
336*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
337*c2c66affSColin Finck     //Sequence requirements 23.1.1 Table 67:
338*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first));
339*c2c66affSColin Finck     if (__first != __last) _Invalidate_all();
340*c2c66affSColin Finck     _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
341*c2c66affSColin Finck   }
342*c2c66affSColin Finck 
insert(iterator __pos,iterator __first,iterator __last)343*c2c66affSColin Finck   void insert(iterator __pos,
344*c2c66affSColin Finck               iterator __first, iterator __last) {
345*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
346*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last))
347*c2c66affSColin Finck     //Sequence requirements 23.1.1 Table 67:
348*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_not_owner(&_M_iter_list, __first));
349*c2c66affSColin Finck     if (__first != __last) _Invalidate_all();
350*c2c66affSColin Finck     _M_non_dbg_impl.insert(__pos._M_iterator, __first._M_iterator, __last._M_iterator);
351*c2c66affSColin Finck   }
352*c2c66affSColin Finck #endif
353*c2c66affSColin Finck 
354*c2c66affSColin Finck #if !defined (_STLP_DONT_SUP_DFLT_PARAM)
355*c2c66affSColin Finck   void resize(size_type __new_size, const value_type& __x = _Tp()) {
356*c2c66affSColin Finck #else
357*c2c66affSColin Finck   void resize(size_type __new_size, const value_type& __x) {
358*c2c66affSColin Finck #endif
359*c2c66affSColin Finck     if (__new_size != size()) {
360*c2c66affSColin Finck       if ((__new_size > size()) || (__new_size < size() - 1))
361*c2c66affSColin Finck         _Invalidate_all();
362*c2c66affSColin Finck       else
363*c2c66affSColin Finck         _Invalidate_iterator(end());
364*c2c66affSColin Finck     }
365*c2c66affSColin Finck     _M_non_dbg_impl.resize(__new_size, __x);
366*c2c66affSColin Finck   }
367*c2c66affSColin Finck 
368*c2c66affSColin Finck #if defined (_STLP_DONT_SUP_DFLT_PARAM)
resize(size_type new_size)369*c2c66affSColin Finck   void resize(size_type new_size) { resize(new_size, _STLP_DEFAULT_CONSTRUCTED(_Tp)); }
370*c2c66affSColin Finck #endif
371*c2c66affSColin Finck 
372*c2c66affSColin Finck   // Erase
erase(iterator __pos)373*c2c66affSColin Finck   iterator erase(iterator __pos) {
374*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_if_owner(&_M_iter_list, __pos))
375*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV _Dereferenceable(__pos))
376*c2c66affSColin Finck     if (__pos._M_iterator == _M_non_dbg_impl.begin()) {
377*c2c66affSColin Finck       _Invalidate_iterator(__pos);
378*c2c66affSColin Finck     } else {
379*c2c66affSColin Finck       typename _Base::iterator tmp = --(_M_non_dbg_impl.end());
380*c2c66affSColin Finck       if (__pos._M_iterator == tmp)
381*c2c66affSColin Finck         _Invalidate_iterator(__pos);
382*c2c66affSColin Finck       else
383*c2c66affSColin Finck         _Invalidate_all();
384*c2c66affSColin Finck     }
385*c2c66affSColin Finck     return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__pos._M_iterator));
386*c2c66affSColin Finck   }
387*c2c66affSColin Finck 
erase(iterator __first,iterator __last)388*c2c66affSColin Finck   iterator erase(iterator __first, iterator __last) {
389*c2c66affSColin Finck     _STLP_DEBUG_CHECK(_STLP_PRIV __check_range(__first, __last, begin(), end()))
390*c2c66affSColin Finck     if (!empty()) {
391*c2c66affSColin Finck       if (__first._M_iterator == _M_non_dbg_impl.begin() ||
392*c2c66affSColin Finck           __last._M_iterator == _M_non_dbg_impl.end())
393*c2c66affSColin Finck         _Invalidate_iterators(__first, __last);
394*c2c66affSColin Finck       else
395*c2c66affSColin Finck         _Invalidate_all();
396*c2c66affSColin Finck     }
397*c2c66affSColin Finck     return iterator (&_M_iter_list, _M_non_dbg_impl.erase(__first._M_iterator, __last._M_iterator));
398*c2c66affSColin Finck   }
399*c2c66affSColin Finck 
clear()400*c2c66affSColin Finck   void clear() {
401*c2c66affSColin Finck     _Invalidate_all();
402*c2c66affSColin Finck     _M_non_dbg_impl.clear();
403*c2c66affSColin Finck   }
404*c2c66affSColin Finck };
405*c2c66affSColin Finck 
406*c2c66affSColin Finck _STLP_END_NAMESPACE
407*c2c66affSColin Finck 
408*c2c66affSColin Finck #undef _STLP_NON_DBG_DEQUE
409*c2c66affSColin Finck 
410*c2c66affSColin Finck #endif /* _STLP_INTERNAL_DEQUE_H */
411*c2c66affSColin Finck 
412*c2c66affSColin Finck // Local Variables:
413*c2c66affSColin Finck // mode:C++
414*c2c66affSColin Finck // End:
415