ReactOS  0.4.14-dev-49-gfb4591c
_iterator_old.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 1994
4  * Hewlett-Packard Company
5  *
6  * Copyright (c) 1996-1998
7  * Silicon Graphics Computer Systems, Inc.
8  *
9  * Copyright (c) 1997
10  * Moscow Center for SPARC Technology
11  *
12  * Copyright (c) 1999
13  * Boris Fomitchev
14  *
15  * This material is provided "as is", with absolutely no warranty expressed
16  * or implied. Any use is at your own risk.
17  *
18  * Permission to use or copy this software for any purpose is hereby granted
19  * without fee, provided the above notices are retained on all copies.
20  * Permission to modify the code and to distribute modified code is granted,
21  * provided the above notices are retained, and a notice that the code was
22  * modified is included with the above copyright notice.
23  *
24  */
25 
26 /* NOTE: This is an internal header file, included by other STL headers.
27  * You should not attempt to use it directly.
28  */
29 
30 #ifndef _STLP_INTERNAL_ITERATOR_OLD_H
31 #define _STLP_INTERNAL_ITERATOR_OLD_H
32 
33 #ifndef _STLP_INTERNAL_ITERATOR_BASE_H
34 # include <stl/_iterator_base.h>
35 #endif
36 
38 
39 #ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
40 
41 template <class _Container>
43 iterator_category(const back_insert_iterator<_Container>&) { return output_iterator_tag(); }
44 template <class _Container>
46 iterator_category(const front_insert_iterator<_Container>&) { return output_iterator_tag(); }
47 template <class _Container>
49 iterator_category(const insert_iterator<_Container>&) { return output_iterator_tag(); }
50 
51 #endif
52 
53 template <class _BidirectionalIterator, class _Tp,
54  _STLP_DFL_TMPL_PARAM(_Reference, _Tp& ),
55 #if defined (_STLP_MSVC50_COMPATIBILITY)
56 # define __Reference _Reference, class _Pointer
57 # define Reference__ _Reference, _Pointer
58  _STLP_DFL_TMPL_PARAM(_Pointer, _Tp*),
59 #else
60 # define __Reference _Reference
61 # define Reference__ _Reference
62 #endif
63  _STLP_DFL_TYPE_PARAM(_Distance, ptrdiff_t)>
65  typedef reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
66  Reference__, _Distance> _Self;
67  // friend inline bool operator== _STLP_NULL_TMPL_ARGS (const _Self& x, const _Self& y);
68 protected:
69  _BidirectionalIterator current;
70 public:
72  typedef _Tp value_type;
73  typedef _Distance difference_type;
74 # if defined (_STLP_MSVC50_COMPATIBILITY)
75  typedef _Pointer pointer;
76 # else
77  typedef _Tp* pointer;
78 # endif
79  typedef _Reference reference;
80 
82  explicit reverse_bidirectional_iterator(_BidirectionalIterator __x)
83  : current(__x) {}
84  _BidirectionalIterator base() const { return current; }
85  _Reference operator*() const {
86  _BidirectionalIterator __tmp = current;
87  return *(--__tmp);
88  }
89 
91 
93  --current;
94  return *this;
95  }
97  _Self __tmp = *this;
98  --current;
99  return __tmp;
100  }
102  ++current;
103  return *this;
104  }
106  _Self __tmp = *this;
107  ++current;
108  return __tmp;
109  }
110 };
111 
112 #ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
113 template <class _BidirectionalIterator, class _Tp, class __Reference,
114  class _Distance>
117 { return bidirectional_iterator_tag(); }
118 template <class _BidirectionalIterator, class _Tp, class __Reference,
119  class _Distance>
120 inline _Tp* _STLP_CALL
122 { return (_Tp*) 0; }
123 template <class _BidirectionalIterator, class _Tp, class __Reference,
124  class _Distance>
125 inline _Distance* _STLP_CALL
127 { return (_Distance*) 0; }
128 #endif
129 
130 template <class _BidirectionalIterator, class _Tp, class __Reference,
131  class _Distance>
132 inline bool _STLP_CALL operator==(
133  const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
134  Reference__, _Distance>& __x,
135  const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
136  Reference__, _Distance>& __y)
137 { return __x.base() == __y.base(); }
138 
139 #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
140 
141 template <class _BiIter, class _Tp, class __Reference, class _Distance>
142 inline bool _STLP_CALL operator!=(
145 { return !(__x == __y); }
146 
147 #endif
148 
149 #if !defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION )
150 
151 // This is the old version of reverse_iterator, as found in the original
152 // HP STL. It does not use partial specialization.
153 
154 template <class _RandomAccessIterator, class _Tp,
155  _STLP_DFL_TMPL_PARAM(_Reference,_Tp&),
156 # if defined (_STLP_MSVC50_COMPATIBILITY)
157  _STLP_DFL_TMPL_PARAM(_Pointer, _Tp*),
158 # endif
159  _STLP_DFL_TYPE_PARAM(_Distance,ptrdiff_t)>
162 protected:
163  _RandomAccessIterator __current;
164 public:
166  typedef _Tp value_type;
167  typedef _Distance difference_type;
168 # if defined (_STLP_MSVC50_COMPATIBILITY)
169  typedef _Pointer pointer;
170 # else
171  typedef _Tp* pointer;
172 # endif
173  typedef _Reference reference;
174 
176  reverse_iterator(const _Self& __x) : __current(__x.base()) {}
177  explicit reverse_iterator(_RandomAccessIterator __x) : __current(__x) {}
178  _Self& operator=(const _Self& __x) {__current = __x.base(); return *this; }
179 
180  _RandomAccessIterator base() const { return __current; }
181  _Reference operator*() const { return *(__current - (difference_type)1); }
182 
184 
186  --__current;
187  return *this;
188  }
190  _Self __tmp = *this;
191  --__current;
192  return __tmp;
193  }
195  ++__current;
196  return *this;
197  }
199  _Self __tmp = *this;
200  ++__current;
201  return __tmp;
202  }
203  _Self operator+(_Distance __n) const {
204  return _Self(__current - __n);
205  }
206  _Self& operator+=(_Distance __n) {
207  __current -= __n;
208  return *this;
209  }
210  _Self operator-(_Distance __n) const {
211  return _Self(__current + __n);
212  }
213  _Self& operator-=(_Distance __n) {
214  __current += __n;
215  return *this;
216  }
217  _Reference operator[](_Distance __n) const { return *(*this + __n); }
218 };
219 
220 # ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
221 template <class _RandomAccessIterator, class _Tp,
222  class __Reference, class _Distance>
225 { return random_access_iterator_tag(); }
226 template <class _RandomAccessIterator, class _Tp,
227  class __Reference, class _Distance>
229 { return (_Tp*) 0; }
230 template <class _RandomAccessIterator, class _Tp,
231  class __Reference, class _Distance>
232 inline _Distance* _STLP_CALL
234 { return (_Distance*) 0; }
235 # endif
236 
237 template <class _RandomAccessIterator, class _Tp,
238  class __Reference, class _Distance>
239 inline bool _STLP_CALL
240 operator==(const reverse_iterator<_RandomAccessIterator, _Tp,
241  Reference__, _Distance>& __x,
242  const reverse_iterator<_RandomAccessIterator, _Tp,
243  Reference__, _Distance>& __y)
244 {
245  return __x.base() == __y.base();
246 }
247 
248 template <class _RandomAccessIterator, class _Tp,
249  class __Reference, class _Distance>
250 inline bool _STLP_CALL
251 operator<(const reverse_iterator<_RandomAccessIterator, _Tp,
252  Reference__, _Distance>& __x,
253  const reverse_iterator<_RandomAccessIterator, _Tp,
254  Reference__, _Distance>& __y)
255 {
256  return __y.base() < __x.base();
257 }
258 
259 # ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
260 
261 template <class _RandomAccessIterator, class _Tp,
262  class __Reference, class _Distance>
263 inline bool _STLP_CALL
264 operator!=(const reverse_iterator<_RandomAccessIterator, _Tp,
265  Reference__, _Distance>& __x,
266  const reverse_iterator<_RandomAccessIterator, _Tp,
267  Reference__, _Distance>& __y) {
268  return !(__x == __y);
269 }
270 
271 template <class _RandomAccessIterator, class _Tp,
272  class __Reference, class _Distance>
273 inline bool _STLP_CALL
274 operator>(const reverse_iterator<_RandomAccessIterator, _Tp,
275  Reference__, _Distance>& __x,
276  const reverse_iterator<_RandomAccessIterator, _Tp,
277  Reference__, _Distance>& __y) {
278  return __y < __x;
279 }
280 
281 template <class _RandomAccessIterator, class _Tp,
282  class __Reference, class _Distance>
283 inline bool _STLP_CALL
284 operator<=(const reverse_iterator<_RandomAccessIterator, _Tp,
285  Reference__, _Distance>& __x,
286  const reverse_iterator<_RandomAccessIterator, _Tp,
287  Reference__, _Distance>& __y) {
288  return !(__y < __x);
289 }
290 
291 template <class _RandomAccessIterator, class _Tp,
292  class __Reference, class _Distance>
293 inline bool _STLP_CALL
294 operator>=(const reverse_iterator<_RandomAccessIterator, _Tp,
295  Reference__, _Distance>& __x,
296  const reverse_iterator<_RandomAccessIterator, _Tp,
297  Reference__, _Distance>& __y) {
298  return !(__x < __y);
299 }
300 
301 # endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
302 
303 template <class _RandomAccessIterator, class _Tp,
304  class __Reference, class _Distance>
305 inline _Distance _STLP_CALL
306 operator-(const reverse_iterator<_RandomAccessIterator, _Tp,
307  Reference__, _Distance>& __x,
308  const reverse_iterator<_RandomAccessIterator, _Tp,
309  Reference__, _Distance>& __y)
310 {
311  return __y.base() - __x.base();
312 }
313 
314 template <class _RandomAccessIterator, class _Tp,
315  class __Reference, class _Distance>
316 inline reverse_iterator<_RandomAccessIterator, _Tp,
317  Reference__, _Distance> _STLP_CALL
318 operator+(_Distance __n,
319  const reverse_iterator<_RandomAccessIterator, _Tp,
320  Reference__, _Distance>& __x)
321 {
322  return reverse_iterator<_RandomAccessIterator, _Tp,
323  Reference__, _Distance>(__x.base() - __n);
324 }
325 
326 #endif /* ! defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION ) */
327 
329 
330 #endif /* _STLP_INTERNAL_ITERATOR_H */
331 
332 // Local Variables:
333 // mode:C++
334 // End:
#define __Reference
bool _STLP_CALL operator!=(const allocator< _T1 > &, const allocator< _T2 > &) _STLP_NOTHROW
Definition: _alloc.h:384
#define bidirectional_iterator_tag
Definition: _abbrevs.h:27
reverse_iterator(const _Self &__x)
bool _STLP_CALL operator<(const reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > &__x, const reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > &__y)
return __n
Definition: _algo.h:75
#define _STLP_DFL_TMPL_PARAM(classname, defval)
Definition: features.h:338
#define output_iterator_tag
Definition: _abbrevs.h:26
_RandomAccessIterator __current
#define random_access_iterator_tag
Definition: _abbrevs.h:28
reverse_iterator(_RandomAccessIterator __x)
bool _STLP_CALL operator==(const reverse_bidirectional_iterator< _BidirectionalIterator, _Tp, Reference__, _Distance > &__x, const reverse_bidirectional_iterator< _BidirectionalIterator, _Tp, Reference__, _Distance > &__y)
_Reference operator[](_Distance __n) const
_Self & operator--()
_Self & operator=(const _Self &__x)
reverse_bidirectional_iterator(_BidirectionalIterator __x)
Definition: _iterator_old.h:82
_Self operator++(int)
_Self & operator+=(_Distance __n)
_Distance difference_type
_RandomAccessIterator base() const
#define _STLP_DFL_TYPE_PARAM(classname, defval)
Definition: features.h:350
#define Reference__
reverse_bidirectional_iterator< _BidirectionalIterator, _Tp, Reference__, _Distance > _Self
Definition: _iterator_old.h:66
random_access_iterator_tag iterator_category
_Self operator--(int)
_Self operator-(_Distance __n) const
bool _STLP_CALL operator>=(const _Bit_iterator_base &__x, const _Bit_iterator_base &__y)
Definition: _bvector.h:164
reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > _Self
_Reference reference
bool _STLP_CALL operator<=(const _Bit_iterator_base &__x, const _Bit_iterator_base &__y)
Definition: _bvector.h:161
_Self operator+(_Distance __n) const
_Reference operator *() const
Definition: _iterator_old.h:85
_Reference operator *() const
_Self & operator-=(_Distance __n)
bool _STLP_CALL operator>(const _Bit_iterator_base &__x, const _Bit_iterator_base &__y)
Definition: _bvector.h:158
_BidirectionalIterator base() const
Definition: _iterator_old.h:84
#define _STLP_END_NAMESPACE
Definition: features.h:503
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
_STLP_DEFINE_ARROW_OPERATOR _Self & operator++()
bidirectional_iterator_tag iterator_category
Definition: _iterator_old.h:71
#define _STLP_DEFINE_ARROW_OPERATOR
reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > _STLP_CALL operator+(_Distance __n, const reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > &__x)
_BidirectionalIterator current
Definition: _iterator_old.h:69
_Distance _STLP_CALL operator-(const reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > &__x, const reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > &__y)
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_CALL
Definition: _bc.h:131
_STLP_DEFINE_ARROW_OPERATOR _Self & operator++()
Definition: _iterator_old.h:92