ReactOS 0.4.16-dev-226-g79f2289
_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
41template <class _Container>
43iterator_category(const back_insert_iterator<_Container>&) { return output_iterator_tag(); }
44template <class _Container>
46iterator_category(const front_insert_iterator<_Container>&) { return output_iterator_tag(); }
47template <class _Container>
49iterator_category(const insert_iterator<_Container>&) { return output_iterator_tag(); }
50
51#endif
52
53template <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
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);
68protected:
69 _BidirectionalIterator current;
70public:
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
113template <class _BidirectionalIterator, class _Tp, class __Reference,
114 class _Distance>
117{ return bidirectional_iterator_tag(); }
118template <class _BidirectionalIterator, class _Tp, class __Reference,
119 class _Distance>
120inline _Tp* _STLP_CALL
122{ return (_Tp*) 0; }
123template <class _BidirectionalIterator, class _Tp, class __Reference,
124 class _Distance>
125inline _Distance* _STLP_CALL
127{ return (_Distance*) 0; }
128#endif
129
130template <class _BidirectionalIterator, class _Tp, class __Reference,
131 class _Distance>
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
141template <class _BiIter, class _Tp, class __Reference, class _Distance>
142inline 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
154template <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
162protected:
163 _RandomAccessIterator __current;
164public:
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
221template <class _RandomAccessIterator, class _Tp,
222 class __Reference, class _Distance>
225{ return random_access_iterator_tag(); }
226template <class _RandomAccessIterator, class _Tp,
227 class __Reference, class _Distance>
229{ return (_Tp*) 0; }
230template <class _RandomAccessIterator, class _Tp,
231 class __Reference, class _Distance>
232inline _Distance* _STLP_CALL
234{ return (_Distance*) 0; }
235# endif
236
237template <class _RandomAccessIterator, class _Tp,
238 class __Reference, class _Distance>
239inline bool _STLP_CALL
240operator==(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
248template <class _RandomAccessIterator, class _Tp,
249 class __Reference, class _Distance>
250inline bool _STLP_CALL
251operator<(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
261template <class _RandomAccessIterator, class _Tp,
262 class __Reference, class _Distance>
263inline bool _STLP_CALL
264operator!=(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
271template <class _RandomAccessIterator, class _Tp,
272 class __Reference, class _Distance>
273inline bool _STLP_CALL
274operator>(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
281template <class _RandomAccessIterator, class _Tp,
282 class __Reference, class _Distance>
283inline bool _STLP_CALL
284operator<=(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
291template <class _RandomAccessIterator, class _Tp,
292 class __Reference, class _Distance>
293inline bool _STLP_CALL
294operator>=(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
303template <class _RandomAccessIterator, class _Tp,
304 class __Reference, class _Distance>
305inline _Distance _STLP_CALL
306operator-(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
314template <class _RandomAccessIterator, class _Tp,
315 class __Reference, class _Distance>
316inline reverse_iterator<_RandomAccessIterator, _Tp,
317 Reference__, _Distance> _STLP_CALL
318operator+(_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 output_iterator_tag
Definition: _abbrevs.h:26
#define random_access_iterator_tag
Definition: _abbrevs.h:28
#define bidirectional_iterator_tag
Definition: _abbrevs.h:27
return __n
Definition: _algo.h:75
bool _STLP_CALL operator!=(const allocator< _T1 > &, const allocator< _T2 > &) _STLP_NOTHROW
Definition: _alloc.h:384
#define _STLP_CALL
Definition: _bc.h:131
bool _STLP_CALL operator>(const _Bit_iterator_base &__x, const _Bit_iterator_base &__y)
Definition: _bvector.h:158
bool _STLP_CALL operator>=(const _Bit_iterator_base &__x, const _Bit_iterator_base &__y)
Definition: _bvector.h:164
bool _STLP_CALL operator<=(const _Bit_iterator_base &__x, const _Bit_iterator_base &__y)
Definition: _bvector.h:161
_Distance _STLP_CALL operator-(const reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > &__x, const reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > &__y)
#define __Reference
#define Reference__
reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > _STLP_CALL operator+(_Distance __n, const reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > &__x)
bool _STLP_CALL operator<(const reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > &__x, const reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > &__y)
bool _STLP_CALL operator==(const reverse_bidirectional_iterator< _BidirectionalIterator, _Tp, Reference__, _Distance > &__x, const reverse_bidirectional_iterator< _BidirectionalIterator, _Tp, Reference__, _Distance > &__y)
#define _STLP_DEFINE_ARROW_OPERATOR
_BidirectionalIterator base() const
Definition: _iterator_old.h:84
_STLP_DEFINE_ARROW_OPERATOR _Self & operator++()
Definition: _iterator_old.h:92
reverse_bidirectional_iterator< _BidirectionalIterator, _Tp, Reference__, _Distance > _Self
Definition: _iterator_old.h:66
reverse_bidirectional_iterator(_BidirectionalIterator __x)
Definition: _iterator_old.h:82
bidirectional_iterator_tag iterator_category
Definition: _iterator_old.h:71
_Reference operator*() const
Definition: _iterator_old.h:85
_BidirectionalIterator current
Definition: _iterator_old.h:69
_Self & operator=(const _Self &__x)
reverse_iterator< _RandomAccessIterator, _Tp, Reference__, _Distance > _Self
_Reference operator[](_Distance __n) const
_Self operator--(int)
_Self & operator--()
_Self operator++(int)
_STLP_DEFINE_ARROW_OPERATOR _Self & operator++()
_Reference operator*() const
_Self operator+(_Distance __n) const
_Self operator-(_Distance __n) const
_Self & operator+=(_Distance __n)
_RandomAccessIterator __current
random_access_iterator_tag iterator_category
reverse_iterator(_RandomAccessIterator __x)
_RandomAccessIterator base() const
_Distance difference_type
reverse_iterator(const _Self &__x)
_Self & operator-=(_Distance __n)
_Reference reference
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define _STLP_DFL_TMPL_PARAM(classname, defval)
Definition: features.h:338
#define _STLP_DFL_TYPE_PARAM(classname, defval)
Definition: features.h:350
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
GLsizei const GLvoid * pointer
Definition: glext.h:5848
struct task_struct * current
Definition: linux.c:32