_iterator_base.h revision e46c9386c4f79aa40185f79a19fc5b2a7ef528b3
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_BASE_H
31#define _STLP_INTERNAL_ITERATOR_BASE_H
32
33#ifndef _STLP_INTERNAL_CSTDDEF
34#  include <stl/_cstddef.h>
35#endif
36
37//# if defined  (_STLP_IMPORT_VENDOR_CSTD) && ! defined (_STLP_VENDOR_GLOBAL_CSTD)
38//_STLP_BEGIN_NAMESPACE
39//using namespace _STLP_VENDOR_CSTD;
40//_STLP_END_NAMESPACE
41//#endif /* _STLP_IMPORT_VENDOR_CSTD */
42
43#if !defined(_STLP_USE_OLD_HP_ITERATOR_QUERIES) && !defined(_STLP_CLASS_PARTIAL_SPECIALIZATION)
44#  ifndef _STLP_TYPE_TRAITS_H
45#    include <stl/type_traits.h>
46#  endif
47#endif
48
49_STLP_BEGIN_NAMESPACE
50
51struct input_iterator_tag {};
52struct output_iterator_tag {};
53struct forward_iterator_tag : public input_iterator_tag {};
54struct bidirectional_iterator_tag : public forward_iterator_tag {};
55struct random_access_iterator_tag : public bidirectional_iterator_tag {};
56
57template <class _Category, class _Tp, _STLP_DFL_TMPL_PARAM(_Distance,ptrdiff_t),
58          _STLP_DFL_TMPL_PARAM(_Pointer,_Tp*), _STLP_DFL_TMPL_PARAM(_Reference,_Tp&) >
59struct iterator {
60  typedef _Category  iterator_category;
61  typedef _Tp        value_type;
62  typedef _Distance  difference_type;
63  typedef _Pointer   pointer;
64  typedef _Reference reference;
65};
66_STLP_TEMPLATE_NULL
67struct iterator<output_iterator_tag, void, void, void, void> {
68  typedef output_iterator_tag  iterator_category;
69#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
70  typedef void                value_type;
71  typedef void                difference_type;
72  typedef void                pointer;
73  typedef void                reference;
74#endif
75};
76
77#if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
78#  define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::iterator_category(_It)
79#  define _STLP_DISTANCE_TYPE(_It, _Tp)     _STLP_STD::distance_type(_It)
80#  define _STLP_VALUE_TYPE(_It, _Tp)        _STLP_STD::value_type(_It)
81//Old HP iterator queries do not give information about the iterator
82//associated reference type so we consider that it is not a real reference.
83#  define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type()
84#else
85#  if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
86#    define _STLP_VALUE_TYPE(_It, _Tp)        (_STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::value_type*)0
87#    define _STLP_DISTANCE_TYPE(_It, _Tp)     (_STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::difference_type*)0
88#    if defined (__BORLANDC__) || defined (__SUNPRO_CC) || ( defined (__MWERKS__) && (__MWERKS__ <= 0x2303)) || \
89       (defined (__sgi) && defined (_COMPILER_VERSION)) || defined (__DMC__)
90#      define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_STD::iterator_traits< _Tp >::iterator_category()
91#    else
92#      define _STLP_ITERATOR_CATEGORY(_It, _Tp) _STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::iterator_category()
93#    endif
94#    define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) _STLP_STD::_IsRefType< _STLP_TYPENAME _STLP_STD::iterator_traits< _Tp >::reference >::_Ret()
95#  else
96#    define _STLP_ITERATOR_CATEGORY(_It, _Tp)   _STLP_STD::__iterator_category(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret())
97#    define _STLP_DISTANCE_TYPE(_It, _Tp)       _STLP_STD::__distance_type(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret())
98#    define _STLP_VALUE_TYPE(_It, _Tp)          _STLP_STD::__value_type(_It, _STLP_STD::_IsPtrType<_Tp>::_Ret())
99#    define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type()
100#  endif
101#endif
102
103#if defined (_STLP_DONT_REDEFINE_STD) && defined (_STLP_WHOLE_NATIVE_STD)
104/* In this mode we will see both STLport implementation and native
105 * one. To allow some interaction between both implementations through
106 * iterators we have to map std iterator categories to stlport ones. This
107 * way we will be able to initialize STLport containers with native
108 * iterators, the other side won't work except when STLport iterators are
109 * simple pointers. */
110
111_STLP_END_NAMESPACE
112
113#  if defined (_STLP_HAS_INCLUDE_NEXT)
114#    include_next <iterator>
115#  else
116#    include _STLP_NATIVE_HEADER(iterator)
117#  endif
118
119_STLP_BEGIN_NAMESPACE
120
121template <class _IteCat>
122struct _CategoryMapping
123{ typedef _IteCat _Tag; };
124
125_STLP_TEMPLATE_NULL
126struct _CategoryMapping<::std::input_iterator_tag>
127{ typedef input_iterator_tag _Tag; };
128_STLP_TEMPLATE_NULL
129struct _CategoryMapping<::std::output_iterator_tag>
130{ typedef output_iterator_tag _Tag; };
131_STLP_TEMPLATE_NULL
132struct _CategoryMapping<::std::forward_iterator_tag>
133{ typedef forward_iterator_tag _Tag; };
134_STLP_TEMPLATE_NULL
135struct _CategoryMapping<::std::bidirectional_iterator_tag>
136{ typedef bidirectional_iterator_tag _Tag; };
137_STLP_TEMPLATE_NULL
138struct _CategoryMapping<::std::random_access_iterator_tag>
139{ typedef random_access_iterator_tag _Tag; };
140
141template <class _Iterator>
142struct iterator_traits {
143  typedef typename _Iterator::iterator_category _OriginalTag;
144  typedef typename _CategoryMapping<_OriginalTag>::_Tag iterator_category;
145#else
146template <class _Iterator>
147struct iterator_traits {
148  typedef typename _Iterator::iterator_category iterator_category;
149#endif
150  typedef typename _Iterator::value_type        value_type;
151  typedef typename _Iterator::difference_type   difference_type;
152  typedef typename _Iterator::pointer           pointer;
153  typedef typename _Iterator::reference         reference;
154};
155
156#if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && !defined (__SUNPRO_CC)
157#  define _STLP_DIFFERENCE_TYPE(_Iterator) typename iterator_traits<_Iterator>::difference_type
158#else
159#  define _STLP_DIFFERENCE_TYPE(_Iterator) ptrdiff_t
160#endif
161
162#ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
163
164// fbp : this order keeps gcc happy
165template <class _Tp>
166struct iterator_traits<const _Tp*> {
167  typedef random_access_iterator_tag  iterator_category;
168  typedef _Tp                         value_type;
169  typedef ptrdiff_t                   difference_type;
170  typedef const _Tp*                  pointer;
171  typedef const _Tp&                  reference;
172};
173
174template <class _Tp>
175struct iterator_traits<_Tp*> {
176  typedef random_access_iterator_tag  iterator_category;
177  typedef _Tp                         value_type;
178  typedef ptrdiff_t                   difference_type;
179  typedef _Tp*                        pointer;
180  typedef _Tp&                        reference;
181};
182
183#  if defined (__BORLANDC__)
184template <class _Tp>
185struct iterator_traits<_Tp* const> {
186  typedef random_access_iterator_tag  iterator_category;
187  typedef _Tp                         value_type;
188  typedef ptrdiff_t                   difference_type;
189  typedef const _Tp*                  pointer;
190  typedef const _Tp&                  reference;
191};
192#  endif
193
194#endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
195
196_STLP_END_NAMESPACE
197#include <stl/_ptrs_specialize.h>
198_STLP_BEGIN_NAMESPACE
199
200#ifndef _STLP_USE_OLD_HP_ITERATOR_QUERIES
201// The overloaded functions iterator_category, distance_type, and
202// value_type are not part of the C++ standard.  (They have been
203// replaced by struct iterator_traits.)  They are included for
204// backward compatibility with the HP STL.
205// We introduce internal names for these functions.
206
207#  ifndef _STLP_CLASS_PARTIAL_SPECIALIZATION
208
209template <class _Tp>
210inline _STLP_STD::random_access_iterator_tag
211__iterator_category(const _Tp*, const __true_type&)
212{ return _STLP_STD::random_access_iterator_tag(); }
213
214template <class _Iter>
215inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::iterator_category
216__iterator_category(const _Iter&, const __false_type&) {
217  typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::iterator_category _Category;
218  return _Category();
219}
220
221template <class _Tp>
222inline ptrdiff_t*
223__distance_type(const _Tp*, const __true_type&)
224{ return __STATIC_CAST(ptrdiff_t*, 0); }
225
226template <class _Iter>
227inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::difference_type*
228__distance_type(const _Iter&, const __false_type&) {
229  typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::difference_type _diff_type;
230  return __STATIC_CAST(_diff_type*,0);
231}
232
233template <class _Tp>
234inline _Tp*
235__value_type(const _Tp*, const __true_type&)
236{ return __STATIC_CAST(_Tp*, 0); }
237
238template <class _Iter>
239inline _STLP_TYPENAME_ON_RETURN_TYPE _STLP_STD::iterator_traits<_Iter>::value_type*
240__value_type(const _Iter&, const __false_type&) {
241  typedef _STLP_TYPENAME _STLP_STD::iterator_traits<_Iter>::value_type _value_type;
242  return __STATIC_CAST(_value_type*,0);
243}
244
245#  endif
246
247#else /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
248template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
249inline _Category _STLP_CALL iterator_category(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return _Category(); }
250template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
251inline _Tp* _STLP_CALL value_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Tp*, 0); }
252template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
253inline _Distance* _STLP_CALL distance_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Distance*, 0); }
254template <class _Tp>
255inline random_access_iterator_tag _STLP_CALL iterator_category(const _Tp*) { return random_access_iterator_tag(); }
256template <class _Tp>
257inline _Tp* _STLP_CALL value_type(const _Tp*) { return __STATIC_CAST(_Tp*, 0); }
258template <class _Tp>
259inline ptrdiff_t* _STLP_CALL distance_type(const _Tp*) { return __STATIC_CAST(ptrdiff_t*, 0); }
260#endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
261
262#if !defined (_STLP_NO_ANACHRONISMS)
263// The base classes input_iterator, output_iterator, forward_iterator,
264// bidirectional_iterator, and random_access_iterator are not part of
265// the C++ standard.  (They have been replaced by struct iterator.)
266// They are included for backward compatibility with the HP STL.
267template <class _Tp, class _Distance> struct input_iterator :
268  public iterator <input_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
269struct output_iterator : public iterator <output_iterator_tag, void, void, void, void> {};
270template <class _Tp, class _Distance> struct forward_iterator :
271  public iterator<forward_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
272template <class _Tp, class _Distance> struct bidirectional_iterator :
273  public iterator<bidirectional_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
274template <class _Tp, class _Distance> struct random_access_iterator :
275  public iterator<random_access_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
276
277#  if defined (_STLP_BASE_MATCH_BUG) && defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
278template <class _Tp, class _Distance>
279inline input_iterator_tag _STLP_CALL
280iterator_category(const input_iterator<_Tp, _Distance>&) { return input_iterator_tag(); }
281inline output_iterator_tag _STLP_CALL
282iterator_category(const output_iterator&) { return output_iterator_tag(); }
283template <class _Tp, class _Distance>
284inline forward_iterator_tag _STLP_CALL
285iterator_category(const forward_iterator<_Tp, _Distance>&) { return forward_iterator_tag(); }
286template <class _Tp, class _Distance>
287inline bidirectional_iterator_tag _STLP_CALL
288iterator_category(const bidirectional_iterator<_Tp, _Distance>&) { return bidirectional_iterator_tag(); }
289template <class _Tp, class _Distance>
290inline random_access_iterator_tag _STLP_CALL
291iterator_category(const random_access_iterator<_Tp, _Distance>&) { return random_access_iterator_tag(); }
292template <class _Tp, class _Distance>
293inline _Tp*  _STLP_CALL value_type(const input_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
294template <class _Tp, class _Distance>
295inline _Tp* _STLP_CALL value_type(const forward_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
296template <class _Tp, class _Distance>
297inline _Tp* _STLP_CALL value_type(const bidirectional_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
298template <class _Tp, class _Distance>
299inline _Tp* _STLP_CALL value_type(const random_access_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
300template <class _Tp, class _Distance>
301inline _Distance* _STLP_CALL distance_type(const input_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); }
302template <class _Tp, class _Distance>
303inline _Distance* _STLP_CALL distance_type(const forward_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); }
304template <class _Tp, class _Distance>
305inline _Distance* _STLP_CALL distance_type(const bidirectional_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0);}
306template <class _Tp, class _Distance>
307inline _Distance* _STLP_CALL distance_type(const random_access_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); }
308#  endif
309#endif
310
311_STLP_MOVE_TO_PRIV_NAMESPACE
312
313template <class _InputIterator>
314inline _STLP_DIFFERENCE_TYPE(_InputIterator) _STLP_CALL
315__distance(const _InputIterator& __first, const _InputIterator& __last,
316           const input_iterator_tag &) {
317  _STLP_DIFFERENCE_TYPE(_InputIterator) __n = 0;
318  _InputIterator __it(__first);
319  while (__it != __last) {
320    ++__it; ++__n;
321  }
322  return __n;
323}
324
325#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
326template <class _ForwardIterator>
327inline _STLP_DIFFERENCE_TYPE(_ForwardIterator) _STLP_CALL
328__distance(const _ForwardIterator& __first, const _ForwardIterator& __last,
329           const forward_iterator_tag &) {
330  _STLP_DIFFERENCE_TYPE(_ForwardIterator) __n = 0;
331  _ForwardIterator __it(__first);
332  while (__it != __last) {
333    ++__it; ++__n;
334  }
335  return __n;
336}
337
338template <class _BidirectionalIterator>
339_STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_BidirectionalIterator) _STLP_CALL
340__distance(const _BidirectionalIterator& __first, const _BidirectionalIterator& __last,
341           const bidirectional_iterator_tag &) {
342  _STLP_DIFFERENCE_TYPE(_BidirectionalIterator) __n = 0;
343  _BidirectionalIterator __it(__first);
344  while (__it != __last) {
345    ++__it; ++__n;
346  }
347  return __n;
348}
349#endif
350
351template <class _RandomAccessIterator>
352inline _STLP_DIFFERENCE_TYPE(_RandomAccessIterator) _STLP_CALL
353__distance(const _RandomAccessIterator& __first, const _RandomAccessIterator& __last,
354           const random_access_iterator_tag &)
355{ return __last - __first; }
356
357_STLP_MOVE_TO_STD_NAMESPACE
358
359template <class _InputIterator>
360inline _STLP_DIFFERENCE_TYPE(_InputIterator) _STLP_CALL
361distance(_InputIterator __first, _InputIterator __last)
362{ return _STLP_PRIV __distance(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator)); }
363
364#if !defined (_STLP_NO_ANACHRONISMS)
365template <class _InputIterator, class _Distance>
366inline void _STLP_CALL distance(const _InputIterator& __first,
367                                const _InputIterator& __last, _Distance& __n)
368{ __n += _STLP_STD::distance(__first, __last); }
369
370#  if defined (_STLP_MSVC)
371// MSVC specific
372template <class _InputIterator, class _Dist>
373inline void  _STLP_CALL _Distance(_InputIterator __first,
374                                  _InputIterator __last, _Dist& __n)
375{ __n += _STLP_STD::distance(__first, __last); }
376#  endif
377#endif
378
379// fbp: those are being used for iterator/const_iterator definitions everywhere
380template <class _Tp>
381struct _Nonconst_traits;
382
383template <class _Tp>
384struct _Const_traits {
385  typedef _Tp value_type;
386  typedef const _Tp&  reference;
387  typedef const _Tp*  pointer;
388  typedef _Const_traits<_Tp> _ConstTraits;
389  typedef _Nonconst_traits<_Tp> _NonConstTraits;
390};
391
392template <class _Tp>
393struct _Nonconst_traits {
394  typedef _Tp value_type;
395  typedef _Tp& reference;
396  typedef _Tp* pointer;
397  typedef _Const_traits<_Tp> _ConstTraits;
398  typedef _Nonconst_traits<_Tp> _NonConstTraits;
399};
400
401/*
402 * dums: A special iterator/const_iterator traits for set and multiset for which even
403 * the iterator is not mutable
404 */
405template <class _Tp>
406struct _Nonconst_Const_traits;
407
408template <class _Tp>
409struct _Const_Const_traits {
410  typedef _Tp value_type;
411  typedef const _Tp&  reference;
412  typedef const _Tp*  pointer;
413  typedef _Const_Const_traits<_Tp> _ConstTraits;
414  typedef _Nonconst_Const_traits<_Tp> _NonConstTraits;
415};
416
417template <class _Tp>
418struct _Nonconst_Const_traits {
419  typedef _Tp value_type;
420  typedef const _Tp& reference;
421  typedef const _Tp* pointer;
422  typedef _Const_Const_traits<_Tp> _ConstTraits;
423  typedef _Nonconst_Const_traits<_Tp> _NonConstTraits;
424};
425
426/*
427 * A macro to generate a new iterator traits from one of the
428 * previous one. Changing the iterator traits type make iterators
429 * from different containers not comparable.
430 */
431#define _STLP_CREATE_ITERATOR_TRAITS_BASE(Motif, Traits)        \
432template <class _Tp>                                            \
433struct _##Motif;                                                \
434template <class _Tp>                                            \
435struct _Const##Motif : public _STLP_STD::_Const_##Traits<_Tp> {  \
436  typedef _Const##Motif<_Tp> _ConstTraits;                      \
437  typedef _##Motif<_Tp> _NonConstTraits;                        \
438};                                                              \
439template <class _Tp>                                            \
440struct _##Motif : public _STLP_STD::_Nonconst_##Traits<_Tp> {    \
441  typedef _Const##Motif<_Tp> _ConstTraits;                      \
442  typedef _##Motif<_Tp> _NonConstTraits;                        \
443};
444
445#define _STLP_CREATE_ITERATOR_TRAITS(Motif, Traits)             \
446_STLP_MOVE_TO_PRIV_NAMESPACE                                    \
447_STLP_CREATE_ITERATOR_TRAITS_BASE(Motif, Traits)                \
448_STLP_MOVE_TO_STD_NAMESPACE
449
450#define _STLP_CREATE_HASH_ITERATOR_TRAITS(Motif, Traits)        \
451_STLP_MOVE_TO_PRIV_NAMESPACE                                    \
452_STLP_CREATE_ITERATOR_TRAITS_BASE(NonLocal##Motif, Traits)      \
453_STLP_CREATE_ITERATOR_TRAITS_BASE(Local##Motif, Traits)         \
454template <class _Tp>                                            \
455struct _##Motif {                                               \
456  typedef _ConstNonLocal##Motif<_Tp> _ConstTraits;              \
457  typedef _NonLocal##Motif<_Tp> _NonConstTraits;                \
458  typedef _ConstLocal##Motif<_Tp> _ConstLocalTraits;            \
459  typedef _Local##Motif<_Tp> _NonConstLocalTraits;              \
460};                                                              \
461_STLP_MOVE_TO_STD_NAMESPACE
462
463/*
464#  if defined (_STLP_BASE_TYPEDEF_BUG)
465// this workaround is needed for SunPro 4.0.1
466template <class _Traits>
467struct __cnst_traits_aux : private _Traits {
468  typedef typename _Traits::value_type value_type;
469};
470#  define __TRAITS_VALUE_TYPE(_Traits) __cnst_traits_aux<_Traits>::value_type
471#  else
472#  define __TRAITS_VALUE_TYPE(_Traits) _Traits::value_type
473#  endif
474*/
475
476_STLP_MOVE_TO_PRIV_NAMESPACE
477
478template <class _InputIter, class _Distance>
479_STLP_INLINE_LOOP void _STLP_CALL
480__advance(_InputIter& __i, _Distance __n, const input_iterator_tag &)
481{ while (__n--) ++__i; }
482
483// fbp : added output iterator tag variant
484template <class _InputIter, class _Distance>
485_STLP_INLINE_LOOP void _STLP_CALL
486__advance(_InputIter& __i, _Distance __n, const output_iterator_tag &)
487{ while (__n--) ++__i; }
488
489#if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
490template <class _ForwardIterator, class _Distance>
491_STLP_INLINE_LOOP void _STLP_CALL
492__advance(_ForwardIterator& i, _Distance n, const forward_iterator_tag &)
493{ while (n--) ++i; }
494#endif
495
496template <class _BidirectionalIterator, class _Distance>
497_STLP_INLINE_LOOP void _STLP_CALL
498__advance(_BidirectionalIterator& __i, _Distance __n,
499          const bidirectional_iterator_tag &) {
500  if (__n > 0)
501    while (__n--) ++__i;
502  else
503    while (__n++) --__i;
504}
505
506template <class _RandomAccessIterator, class _Distance>
507inline void _STLP_CALL
508__advance(_RandomAccessIterator& __i, _Distance __n,
509          const random_access_iterator_tag &)
510{ __i += __n; }
511
512_STLP_MOVE_TO_STD_NAMESPACE
513
514template <class _InputIterator, class _Distance>
515inline void _STLP_CALL advance(_InputIterator& __i, _Distance __n)
516{ _STLP_PRIV __advance(__i, __n, _STLP_ITERATOR_CATEGORY(__i, _InputIterator)); }
517
518_STLP_END_NAMESPACE
519
520#endif /* _STLP_INTERNAL_ITERATOR_BASE_H */
521
522
523// Local Variables:
524// mode:C++
525// End:
526