/home/ntakagi/work/STLport-5.1.5/stlport/stl/_iterator_base.h

Go to the documentation of this file.
00001 /*
00002  *
00003  * Copyright (c) 1994
00004  * Hewlett-Packard Company
00005  *
00006  * Copyright (c) 1996-1998
00007  * Silicon Graphics Computer Systems, Inc.
00008  *
00009  * Copyright (c) 1997
00010  * Moscow Center for SPARC Technology
00011  *
00012  * Copyright (c) 1999
00013  * Boris Fomitchev
00014  *
00015  * This material is provided "as is", with absolutely no warranty expressed
00016  * or implied. Any use is at your own risk.
00017  *
00018  * Permission to use or copy this software for any purpose is hereby granted
00019  * without fee, provided the above notices are retained on all copies.
00020  * Permission to modify the code and to distribute modified code is granted,
00021  * provided the above notices are retained, and a notice that the code was
00022  * modified is included with the above copyright notice.
00023  *
00024  */
00025 
00026 /* NOTE: This is an internal header file, included by other STL headers.
00027  *   You should not attempt to use it directly.
00028  */
00029 
00030 #ifndef _STLP_INTERNAL_ITERATOR_BASE_H
00031 #define _STLP_INTERNAL_ITERATOR_BASE_H
00032 
00033 #ifndef _STLP_INTERNAL_CSTDDEF
00034 #  include <stl/_cstddef.h>
00035 #endif
00036 
00037 //# if defined  (_STLP_IMPORT_VENDOR_CSTD) && ! defined (_STLP_VENDOR_GLOBAL_CSTD)
00038 //_STLP_BEGIN_NAMESPACE
00039 //using namespace _STLP_VENDOR_CSTD;
00040 //_STLP_END_NAMESPACE
00041 //#endif /* _STLP_IMPORT_VENDOR_CSTD */
00042 
00043 #if !defined(_STLP_USE_OLD_HP_ITERATOR_QUERIES) && !defined(_STLP_CLASS_PARTIAL_SPECIALIZATION)
00044 #  ifndef _STLP_TYPE_TRAITS_H
00045 #    include <stl/type_traits.h>
00046 #  endif
00047 #endif
00048 
00049 _STLP_BEGIN_NAMESPACE
00050 
00051 struct input_iterator_tag {};
00052 struct output_iterator_tag {};
00053 struct forward_iterator_tag : public input_iterator_tag {};
00054 struct bidirectional_iterator_tag : public forward_iterator_tag {};
00055 struct random_access_iterator_tag : public bidirectional_iterator_tag {};
00056 
00057 
00058 template <class _Category, class _Tp, _STLP_DFL_TMPL_PARAM(_Distance,ptrdiff_t),
00059           _STLP_DFL_TMPL_PARAM(_Pointer,_Tp*), _STLP_DFL_TMPL_PARAM(_Reference,_Tp&) >
00060 struct iterator {
00061   typedef _Category  iterator_category;
00062   typedef _Tp        value_type;
00063   typedef _Distance  difference_type;
00064   typedef _Pointer   pointer;
00065   typedef _Reference reference;
00066 };
00067 _STLP_TEMPLATE_NULL
00068 struct iterator<output_iterator_tag, void, void, void, void> {
00069   typedef output_iterator_tag  iterator_category;
00070 #ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
00071   typedef void                value_type;
00072   typedef void                difference_type;
00073   typedef void                pointer;
00074   typedef void                reference;
00075 #endif
00076 };
00077 
00078 #if defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
00079 #  define _STLP_ITERATOR_CATEGORY(_It, _Tp) iterator_category(_It)
00080 #  define _STLP_DISTANCE_TYPE(_It, _Tp)     distance_type(_It)
00081 #  define _STLP_VALUE_TYPE(_It, _Tp)        value_type(_It)
00082 //Old HP iterator queries do not give information about the iterator
00083 //associated reference type so we consider that it is not a real reference.
00084 #  define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type()
00085 #else
00086 #  if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION)
00087 #    define _STLP_VALUE_TYPE(_It, _Tp)        (typename iterator_traits< _Tp >::value_type*)0
00088 #    define _STLP_DISTANCE_TYPE(_It, _Tp)     (typename iterator_traits< _Tp >::difference_type*)0
00089 #    if defined (__BORLANDC__) || defined (__SUNPRO_CC) || ( defined (__MWERKS__) && (__MWERKS__ <= 0x2303)) || ( defined (__sgi) && defined (_COMPILER_VERSION)) || defined (__DMC__)
00090 #      define _STLP_ITERATOR_CATEGORY(_It, _Tp) iterator_traits< _Tp >::iterator_category()
00091 #    else
00092 #      define _STLP_ITERATOR_CATEGORY(_It, _Tp) typename iterator_traits< _Tp >::iterator_category()
00093 #    endif
00094 #    define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) _IsRefType< typename iterator_traits< _Tp >::reference >::_Ret()
00095 #  else
00096 #    define _STLP_ITERATOR_CATEGORY(_It, _Tp)   __iterator_category(_It, _IsPtrType<_Tp>::_Ret())
00097 #    define _STLP_DISTANCE_TYPE(_It, _Tp)       (ptrdiff_t*)0
00098 #    define _STLP_VALUE_TYPE(_It, _Tp)          __value_type(_It, _IsPtrType<_Tp>::_Ret() )
00099 #    define _STLP_IS_REF_TYPE_REAL_REF(_It, _Tp) __false_type()
00100 #  endif
00101 #endif
00102 
00103 template <class _Iterator>
00104 struct iterator_traits {
00105   typedef typename _Iterator::iterator_category iterator_category;
00106   typedef typename _Iterator::value_type        value_type;
00107   typedef typename _Iterator::difference_type   difference_type;
00108   typedef typename _Iterator::pointer           pointer;
00109   typedef typename _Iterator::reference         reference;
00110 };
00111 
00112 
00113 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) && ! defined (__SUNPRO_CC)
00114 #  define _STLP_DIFFERENCE_TYPE(_Iterator) typename iterator_traits<_Iterator>::difference_type
00115 #else
00116 #  define _STLP_DIFFERENCE_TYPE(_Iterator) ptrdiff_t
00117 #endif
00118 
00119 #ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
00120 
00121 // fbp : this order keeps gcc happy
00122 template <class _Tp>
00123 struct iterator_traits<const _Tp*> {
00124   typedef random_access_iterator_tag  iterator_category;
00125   typedef _Tp                         value_type;
00126   typedef ptrdiff_t                   difference_type;
00127   typedef const _Tp*                  pointer;
00128   typedef const _Tp&                  reference;
00129 };
00130 
00131 template <class _Tp>
00132 struct iterator_traits<_Tp*> {
00133   typedef random_access_iterator_tag  iterator_category;
00134   typedef _Tp                         value_type;
00135   typedef ptrdiff_t                   difference_type;
00136   typedef _Tp*                        pointer;
00137   typedef _Tp&                        reference;
00138 };
00139 
00140 #  if defined (__BORLANDC__)
00141 template <class _Tp>
00142 struct iterator_traits<_Tp* const> {
00143   typedef random_access_iterator_tag  iterator_category;
00144   typedef _Tp                         value_type;
00145   typedef ptrdiff_t                   difference_type;
00146   typedef const _Tp*                  pointer;
00147   typedef const _Tp&                  reference;
00148 };
00149 #  endif
00150 
00151 #endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
00152 
00153 
00154 #if defined (_STLP_CLASS_PARTIAL_SPECIALIZATION) || \
00155    (defined (_STLP_SIMULATE_PARTIAL_SPEC_FOR_TYPE_TRAITS) && ! defined (_STLP_NO_ARROW_OPERATOR))
00156 #  define _STLP_POINTERS_SPECIALIZE( _TpP )
00157 #  define _STLP_DEFINE_ARROW_OPERATOR  pointer operator->() const { return &(operator*()); }
00158 #else
00159 #  include <stl/_ptrs_specialize.h>
00160 #endif
00161 
00162 #ifndef _STLP_USE_OLD_HP_ITERATOR_QUERIES
00163 // The overloaded functions iterator_category, distance_type, and
00164 // value_type are not part of the C++ standard.  (They have been
00165 // replaced by struct iterator_traits.)  They are included for
00166 // backward compatibility with the HP STL.
00167 // We introduce internal names for these functions.
00168 
00169 #  ifdef _STLP_CLASS_PARTIAL_SPECIALIZATION
00170 
00171 template <class _Iter>
00172 inline typename iterator_traits<_Iter>::iterator_category __iterator_category(const _Iter&) {
00173   typedef typename iterator_traits<_Iter>::iterator_category _Category;
00174   return _Category();
00175 }
00176 
00177 template <class _Iter>
00178 inline typename iterator_traits<_Iter>::difference_type* __distance_type(const _Iter&) {
00179   typedef typename iterator_traits<_Iter>::difference_type _diff_type;
00180   return __STATIC_CAST(_diff_type*,0);
00181 }
00182 
00183 template <class _Iter>
00184 inline typename iterator_traits<_Iter>::value_type* __value_type(const _Iter&) {
00185   typedef typename iterator_traits<_Iter>::value_type _value_type;
00186   return __STATIC_CAST(_value_type*,0);
00187 }
00188 
00189 #  else /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
00190 
00191 template <class _Iter>
00192 inline random_access_iterator_tag
00193 __iterator_category(const _Iter&, const __true_type&) {
00194   return random_access_iterator_tag();
00195 }
00196 
00197 template <class _Iter>
00198 inline _STLP_TYPENAME_ON_RETURN_TYPE iterator_traits<_Iter>::iterator_category
00199 __iterator_category(const _Iter&, const __false_type&) {
00200   typedef typename iterator_traits<_Iter>::iterator_category _Category;
00201   return _Category();
00202 }
00203 
00204 
00205 template <class _Iter>
00206 inline ptrdiff_t* _STLP_CALL __distance_type(const _Iter&) { return __STATIC_CAST(ptrdiff_t*, 0); }
00207 
00208 template <class _Iter>
00209 inline _STLP_TYPENAME_ON_RETURN_TYPE iterator_traits<_Iter>::value_type*
00210 __value_type(const _Iter&, const __false_type&) {
00211   typedef typename iterator_traits<_Iter>::value_type _value_type;
00212   return __STATIC_CAST(_value_type*,0);
00213 }
00214 
00215 template <class _Tp>
00216 inline _Tp*
00217 __value_type(const _Tp*, const __true_type&) {
00218   return __STATIC_CAST(_Tp*, 0);
00219 }
00220 
00221 #  endif /* _STLP_CLASS_PARTIAL_SPECIALIZATION */
00222 
00223 #else /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
00224 template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
00225 inline _Category _STLP_CALL iterator_category(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return _Category(); }
00226 template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
00227 inline _Tp* _STLP_CALL value_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Tp*, 0); }
00228 template <class _Category, class _Tp, class _Distance, class _Pointer, class _Reference>
00229 inline _Distance* _STLP_CALL distance_type(const iterator<_Category,_Tp,_Distance,_Pointer,_Reference>&) { return __STATIC_CAST(_Distance*, 0); }
00230 template <class _Tp>
00231 inline random_access_iterator_tag _STLP_CALL iterator_category(const _Tp*) { return random_access_iterator_tag(); }
00232 template <class _Tp>
00233 inline _Tp* _STLP_CALL value_type(const _Tp*) { return __STATIC_CAST(_Tp*, 0); }
00234 template <class _Tp>
00235 inline ptrdiff_t* _STLP_CALL distance_type(const _Tp*) { return __STATIC_CAST(ptrdiff_t*, 0); }
00236 #endif /* _STLP_USE_OLD_HP_ITERATOR_QUERIES */
00237 
00238 # if ! defined (_STLP_NO_ANACHRONISMS)
00239 // The base classes input_iterator, output_iterator, forward_iterator,
00240 // bidirectional_iterator, and random_access_iterator are not part of
00241 // the C++ standard.  (They have been replaced by struct iterator.)
00242 // They are included for backward compatibility with the HP STL.
00243 template <class _Tp, class _Distance> struct input_iterator :
00244   public iterator <input_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
00245 struct output_iterator : public iterator <output_iterator_tag, void, void, void, void> {};
00246 template <class _Tp, class _Distance> struct forward_iterator :
00247   public iterator<forward_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
00248 template <class _Tp, class _Distance> struct bidirectional_iterator :
00249   public iterator<bidirectional_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
00250 template <class _Tp, class _Distance> struct random_access_iterator :
00251   public iterator<random_access_iterator_tag, _Tp, _Distance, _Tp*, _Tp&> {};
00252 
00253 # if defined (_STLP_BASE_MATCH_BUG) && defined (_STLP_USE_OLD_HP_ITERATOR_QUERIES)
00254 template <class _Tp, class _Distance>
00255 inline input_iterator_tag _STLP_CALL
00256 iterator_category(const input_iterator<_Tp, _Distance>&) { return input_iterator_tag(); }
00257 inline output_iterator_tag _STLP_CALL
00258 iterator_category(const output_iterator&) { return output_iterator_tag(); }
00259 template <class _Tp, class _Distance>
00260 inline forward_iterator_tag _STLP_CALL
00261 iterator_category(const forward_iterator<_Tp, _Distance>&) { return forward_iterator_tag(); }
00262 template <class _Tp, class _Distance>
00263 inline bidirectional_iterator_tag _STLP_CALL
00264 iterator_category(const bidirectional_iterator<_Tp, _Distance>&) { return bidirectional_iterator_tag(); }
00265 template <class _Tp, class _Distance>
00266 inline random_access_iterator_tag _STLP_CALL
00267 iterator_category(const random_access_iterator<_Tp, _Distance>&) { return random_access_iterator_tag(); }
00268 template <class _Tp, class _Distance>
00269 inline _Tp*  _STLP_CALL value_type(const input_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
00270 template <class _Tp, class _Distance>
00271 inline _Tp* _STLP_CALL value_type(const forward_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
00272 template <class _Tp, class _Distance>
00273 inline _Tp* _STLP_CALL value_type(const bidirectional_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
00274 template <class _Tp, class _Distance>
00275 inline _Tp* _STLP_CALL value_type(const random_access_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Tp*, 0); }
00276 template <class _Tp, class _Distance>
00277 inline _Distance* _STLP_CALL distance_type(const input_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); }
00278 template <class _Tp, class _Distance>
00279 inline _Distance* _STLP_CALL distance_type(const forward_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); }
00280 template <class _Tp, class _Distance>
00281 inline _Distance* _STLP_CALL distance_type(const bidirectional_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0);}
00282 template <class _Tp, class _Distance>
00283 inline _Distance* _STLP_CALL distance_type(const random_access_iterator<_Tp, _Distance>&) { return __STATIC_CAST(_Distance*, 0); }
00284 # endif /* BASE_MATCH */
00285 
00286 #endif /* _STLP_NO_ANACHRONISMS */
00287 
00288 template <class _InputIterator, class _Distance>
00289 inline void _STLP_CALL __distance(const _InputIterator& __first, const _InputIterator& __last,
00290                                   _Distance& __n, const input_iterator_tag &) {
00291   _InputIterator __it(__first);
00292   while (__it != __last) { ++__it; ++__n; }
00293 }
00294 
00295 
00296 # if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
00297 template <class _ForwardIterator, class _Distance>
00298 inline void _STLP_CALL __distance(const _ForwardIterator& __first, const _ForwardIterator& __last,
00299                                   _Distance& __n, const forward_iterator_tag &) {
00300   _ForwardIterator __it(__first);
00301   while (__it != __last) { ++__first; ++__n; }
00302 }
00303 
00304 template <class _BidirectionalIterator, class _Distance>
00305 _STLP_INLINE_LOOP void _STLP_CALL __distance(const _BidirectionalIterator& __first,
00306                                              const _BidirectionalIterator& __last,
00307                                              _Distance& __n, const bidirectional_iterator_tag &) {
00308   _BidirectionalIterator __it(__first);
00309   while (__it != __last) { ++__it; ++__n; }
00310 }
00311 # endif
00312 
00313 template <class _RandomAccessIterator, class _Distance>
00314 inline void _STLP_CALL __distance(const _RandomAccessIterator& __first,
00315                                   const _RandomAccessIterator& __last,
00316                                   _Distance& __n, const random_access_iterator_tag &) {
00317   __n += __last - __first;
00318 }
00319 
00320 #ifndef _STLP_NO_ANACHRONISMS
00321 template <class _InputIterator, class _Distance>
00322 inline void _STLP_CALL distance(const _InputIterator& __first,
00323         const _InputIterator& __last, _Distance& __n) {
00324   __distance(__first, __last, __n, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
00325 }
00326 #endif
00327 
00328 template <class _InputIterator>
00329 inline _STLP_DIFFERENCE_TYPE(_InputIterator) _STLP_CALL
00330 __distance(const _InputIterator& __first, const _InputIterator& __last, const input_iterator_tag &) {
00331   _STLP_DIFFERENCE_TYPE(_InputIterator) __n = 0;
00332   _InputIterator __it(__first);
00333   while (__it != __last) {
00334     ++__it; ++__n;
00335   }
00336   return __n;
00337 }
00338 
00339 # if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
00340 template <class _ForwardIterator>
00341 inline _STLP_DIFFERENCE_TYPE(_ForwardIterator) _STLP_CALL
00342 __distance(const _ForwardIterator& __first, const _ForwardIterator& __last,
00343            const forward_iterator_tag &)
00344 {
00345   _STLP_DIFFERENCE_TYPE(_ForwardIterator) __n = 0;
00346   _ForwardIterator __it(__first);
00347   while (__it != __last) {
00348     ++__it; ++__n;
00349   }
00350   return __n;
00351 
00352 }
00353 
00354 template <class _BidirectionalIterator>
00355 _STLP_INLINE_LOOP _STLP_DIFFERENCE_TYPE(_BidirectionalIterator) _STLP_CALL
00356 __distance(const _BidirectionalIterator& __first,
00357            const _BidirectionalIterator& __last,
00358            const bidirectional_iterator_tag &) {
00359   _STLP_DIFFERENCE_TYPE(_BidirectionalIterator) __n = 0;
00360   _BidirectionalIterator __it(__first);
00361   while (__it != __last) {
00362     ++__it; ++__n;
00363   }
00364   return __n;
00365 }
00366 # endif
00367 
00368 template <class _RandomAccessIterator>
00369 inline _STLP_DIFFERENCE_TYPE(_RandomAccessIterator) _STLP_CALL
00370 __distance(const _RandomAccessIterator& __first, const _RandomAccessIterator& __last,
00371            const random_access_iterator_tag &) {
00372   return __last - __first;
00373 }
00374 
00375 template <class _InputIterator>
00376 inline _STLP_DIFFERENCE_TYPE(_InputIterator) _STLP_CALL
00377 distance(_InputIterator __first, _InputIterator __last) {
00378   return __distance(__first, __last, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
00379 }
00380 
00381 // fbp: those are being used for iterator/const_iterator definitions everywhere
00382 template <class _Tp>
00383 struct _Nonconst_traits;
00384 
00385 template <class _Tp>
00386 struct _Const_traits {
00387   typedef _Tp value_type;
00388   typedef const _Tp&  reference;
00389   typedef const _Tp*  pointer;
00390   typedef _Const_traits<_Tp> _ConstTraits;
00391   typedef _Nonconst_traits<_Tp> _NonConstTraits;
00392 };
00393 
00394 template <class _Tp>
00395 struct _Nonconst_traits {
00396   typedef _Tp value_type;
00397   typedef _Tp& reference;
00398   typedef _Tp* pointer;
00399   typedef _Const_traits<_Tp> _ConstTraits;
00400   typedef _Nonconst_traits<_Tp> _NonConstTraits;
00401 };
00402 
00403 /*
00404  * dums: A special iterator/const_iterator traits for set and multiset for which even
00405  * the iterator is not mutable
00406  */
00407 template <class _Tp>
00408 struct _Nonconst_Const_traits;
00409 
00410 template <class _Tp>
00411 struct _Const_Const_traits {
00412   typedef _Tp value_type;
00413   typedef const _Tp&  reference;
00414   typedef const _Tp*  pointer;
00415   typedef _Const_Const_traits<_Tp> _ConstTraits;
00416   typedef _Nonconst_Const_traits<_Tp> _NonConstTraits;
00417 };
00418 
00419 template <class _Tp>
00420 struct _Nonconst_Const_traits {
00421   typedef _Tp value_type;
00422   typedef const _Tp& reference;
00423   typedef const _Tp* pointer;
00424   typedef _Const_Const_traits<_Tp> _ConstTraits;
00425   typedef _Nonconst_Const_traits<_Tp> _NonConstTraits;
00426 };
00427 
00428 /*
00429  * A macro to generate a new iterator traits from one of the
00430  * previous one. Changing the iterator traits type make iterators
00431  * from different containers not comparable.
00432  */
00433 #define _STLP_CREATE_ITERATOR_TRAITS_BASE(Motif, Traits)        \
00434 template <class _Tp>                                            \
00435 struct _##Motif;                                                \
00436 template <class _Tp>                                            \
00437 struct _Const##Motif : public _STLP_STD::_Const_##Traits<_Tp> {  \
00438   typedef _Const##Motif<_Tp> _ConstTraits;                      \
00439   typedef _##Motif<_Tp> _NonConstTraits;                        \
00440 };                                                              \
00441 template <class _Tp>                                            \
00442 struct _##Motif : public _STLP_STD::_Nonconst_##Traits<_Tp> {    \
00443   typedef _Const##Motif<_Tp> _ConstTraits;                      \
00444   typedef _##Motif<_Tp> _NonConstTraits;                        \
00445 };
00446 
00447 #define _STLP_CREATE_ITERATOR_TRAITS(Motif, Traits)             \
00448 _STLP_MOVE_TO_PRIV_NAMESPACE                                    \
00449 _STLP_CREATE_ITERATOR_TRAITS_BASE(Motif, Traits)                \
00450 _STLP_MOVE_TO_STD_NAMESPACE
00451 
00452 #define _STLP_CREATE_HASH_ITERATOR_TRAITS(Motif, Traits)        \
00453 _STLP_MOVE_TO_PRIV_NAMESPACE                                    \
00454 _STLP_CREATE_ITERATOR_TRAITS_BASE(NonLocal##Motif, Traits)      \
00455 _STLP_CREATE_ITERATOR_TRAITS_BASE(Local##Motif, Traits)         \
00456 template <class _Tp>                                            \
00457 struct _##Motif {                                               \
00458   typedef _ConstNonLocal##Motif<_Tp> _ConstTraits;              \
00459   typedef _NonLocal##Motif<_Tp> _NonConstTraits;                \
00460   typedef _ConstLocal##Motif<_Tp> _ConstLocalTraits;            \
00461   typedef _Local##Motif<_Tp> _NonConstLocalTraits;              \
00462 };                                                              \
00463 _STLP_MOVE_TO_STD_NAMESPACE
00464 
00465 /*
00466 #  if defined (_STLP_BASE_TYPEDEF_BUG)
00467 // this workaround is needed for SunPro 4.0.1
00468 template <class _Traits>
00469 struct __cnst_traits_aux : private _Traits {
00470   typedef typename _Traits::value_type value_type;
00471 };
00472 #  define __TRAITS_VALUE_TYPE(_Traits) __cnst_traits_aux<_Traits>::value_type
00473 #  else
00474 #  define __TRAITS_VALUE_TYPE(_Traits) _Traits::value_type
00475 #  endif
00476 */
00477 
00478 #if defined (_STLP_MSVC)
00479 // MSVC specific
00480 template <class _InputIterator, class _Dist>
00481 inline void  _STLP_CALL _Distance(_InputIterator __first,
00482                                   _InputIterator __last, _Dist& __n) {
00483   __distance(__first, __last, __n, _STLP_ITERATOR_CATEGORY(__first, _InputIterator));
00484 }
00485 #endif
00486 
00487 template <class _InputIter, class _Distance>
00488 _STLP_INLINE_LOOP void  _STLP_CALL
00489 __advance(_InputIter& __i, _Distance __n, const input_iterator_tag &) {
00490   while (__n--) ++__i;
00491 }
00492 
00493 // fbp : added output iterator tag variant
00494 template <class _InputIter, class _Distance>
00495 _STLP_INLINE_LOOP void  _STLP_CALL
00496 __advance(_InputIter& __i, _Distance __n, const output_iterator_tag &) {
00497   while (__n--) ++__i;
00498 }
00499 
00500 #if defined (_STLP_NONTEMPL_BASE_MATCH_BUG)
00501 template <class _ForwardIterator, class _Distance>
00502 _STLP_INLINE_LOOP void _STLP_CALL
00503 __advance(_ForwardIterator& i, _Distance n, const forward_iterator_tag &) {
00504   while (n--) ++i;
00505 }
00506 #endif
00507 
00508 template <class _BidirectionalIterator, class _Distance>
00509 _STLP_INLINE_LOOP void _STLP_CALL
00510 __advance(_BidirectionalIterator& __i, _Distance __n,
00511           const bidirectional_iterator_tag &) {
00512   if (__n > 0)
00513     while (__n--) ++__i;
00514   else
00515     while (__n++) --__i;
00516 }
00517 
00518 template <class _RandomAccessIterator, class _Distance>
00519 inline void _STLP_CALL
00520 __advance(_RandomAccessIterator& __i, _Distance __n,
00521           const random_access_iterator_tag &) {
00522   __i += __n;
00523 }
00524 
00525 template <class _InputIterator, class _Distance>
00526 inline void _STLP_CALL advance(_InputIterator& __i, _Distance __n) {
00527   __advance(__i, __n, _STLP_ITERATOR_CATEGORY(__i, _InputIterator));
00528 }
00529 
00530 _STLP_END_NAMESPACE
00531 
00532 #if defined (_STLP_DEBUG) && !defined (_STLP_DEBUG_H)
00533 #  include <stl/debug/_debug.h>
00534 #endif
00535 
00536 #endif /* _STLP_INTERNAL_ITERATOR_BASE_H */
00537 
00538 
00539 // Local Variables:
00540 // mode:C++
00541 // End:



Generated on Mon Mar 10 15:32:27 2008 by  doxygen 1.5.1