epoc32/include/tools/stlport/stl/_iterator_old.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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 
    37 _STLP_BEGIN_NAMESPACE
    38 
    39 # ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
    40 
    41 template <class _Container>
    42 inline output_iterator_tag _STLP_CALL
    43 iterator_category(const back_insert_iterator<_Container>&) { return output_iterator_tag(); }
    44 template <class _Container>
    45 inline output_iterator_tag _STLP_CALL
    46 iterator_category(const front_insert_iterator<_Container>&) { return output_iterator_tag(); }
    47 template <class _Container>
    48 inline output_iterator_tag _STLP_CALL
    49 iterator_category(const insert_iterator<_Container>&) { return output_iterator_tag(); }
    50 
    51 # endif
    52 
    53 # if defined (_STLP_MSVC50_COMPATIBILITY)
    54 # define __Reference _Reference, class _Pointer
    55 # define Reference__ _Reference, _Pointer
    56 template <class _BidirectionalIterator, class _Tp,
    57     _STLP_DFL_TMPL_PARAM(_Reference, _Tp& ),
    58     _STLP_DFL_TMPL_PARAM(_Pointer, _Tp*),
    59     _STLP_DFL_TYPE_PARAM(_Distance, ptrdiff_t)>
    60 # else
    61 # define __Reference _Reference
    62 # define Reference__ _Reference
    63 template <class _BidirectionalIterator, class _Tp, _STLP_DFL_TMPL_PARAM(_Reference, _Tp& ),
    64     _STLP_DFL_TYPE_PARAM(_Distance, ptrdiff_t)>
    65 # endif
    66 class reverse_bidirectional_iterator {
    67   typedef reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
    68                                          Reference__, _Distance> _Self;
    69   //  friend inline bool operator== _STLP_NULL_TMPL_ARGS (const _Self& x, const _Self& y);
    70 protected:
    71   _BidirectionalIterator current;
    72 public:
    73   typedef bidirectional_iterator_tag iterator_category;
    74   typedef _Tp                        value_type;
    75   typedef _Distance                  difference_type;
    76 # if defined (_STLP_MSVC50_COMPATIBILITY)
    77   typedef _Pointer                   pointer;
    78 # else
    79   typedef _Tp*                       pointer;
    80 # endif
    81   typedef _Reference                 reference;
    82 
    83   reverse_bidirectional_iterator() {}
    84   explicit reverse_bidirectional_iterator(_BidirectionalIterator __x)
    85     : current(__x) {}
    86   _BidirectionalIterator base() const { return current; }
    87   _Reference operator*() const {
    88     _BidirectionalIterator __tmp = current;
    89     return *(--__tmp);
    90   }
    91 # if !(defined _STLP_NO_ARROW_OPERATOR)
    92   _STLP_DEFINE_ARROW_OPERATOR
    93 # endif
    94   _Self& operator++() {
    95     --current;
    96     return *this;
    97   }
    98   _Self operator++(int) {
    99     _Self __tmp = *this;
   100     --current;
   101     return __tmp;
   102   }
   103   _Self& operator--() {
   104     ++current;
   105     return *this;
   106   }
   107   _Self operator--(int) {
   108     _Self __tmp = *this;
   109     ++current;
   110     return __tmp;
   111   }
   112 };
   113 
   114 # ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
   115 template <class _BidirectionalIterator, class _Tp, class __Reference,
   116           class _Distance>
   117 inline bidirectional_iterator_tag _STLP_CALL
   118 iterator_category(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&)
   119 { return bidirectional_iterator_tag(); }
   120 template <class _BidirectionalIterator, class _Tp, class __Reference,
   121   class _Distance>
   122 inline _Tp* _STLP_CALL
   123 value_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&)
   124 { return (_Tp*) 0; }
   125 template <class _BidirectionalIterator, class _Tp, class __Reference,
   126           class _Distance>
   127 inline _Distance* _STLP_CALL
   128 distance_type(const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, Reference__, _Distance>&)
   129 { return (_Distance*) 0; }
   130 #endif
   131 
   132 template <class _BidirectionalIterator, class _Tp, class __Reference,
   133           class _Distance>
   134 inline bool  _STLP_CALL operator==(
   135     const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
   136                                                Reference__, _Distance>& __x,
   137     const reverse_bidirectional_iterator<_BidirectionalIterator, _Tp,
   138                                                Reference__, _Distance>& __y)
   139 {
   140   return __x.base() == __y.base();
   141 }
   142 
   143 #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
   144 
   145 template <class _BiIter, class _Tp, class __Reference, class _Distance>
   146 inline bool  _STLP_CALL operator!=(
   147     const reverse_bidirectional_iterator<_BiIter, _Tp, Reference__, _Distance>& __x,
   148     const reverse_bidirectional_iterator<_BiIter, _Tp, Reference__, _Distance>& __y)
   149 {
   150   return !(__x == __y);
   151 }
   152 
   153 #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
   154 
   155 #if ! defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION )
   156 
   157 // This is the old version of reverse_iterator, as found in the original
   158 //  HP STL.  It does not use partial specialization.
   159 
   160 template <class _RandomAccessIterator,
   161 # if defined (__MSL__) && (__MSL__ >= 0x2405) \
   162   || defined(__MRC__) || (defined(__SC__) && !defined(__DMC__))    //*ty 03/22/2001 - give the default to the secont param under MPW.
   163                         // I believe giving the default will cause any harm even though the 2nd type parameter
   164                         // still have to be provided for T* type iterators.
   165   _STLP_DFL_TMPL_PARAM(_Tp,iterator_traits<_RandomAccessIterator>::value_type),
   166 # else
   167   class _Tp,
   168 #endif
   169  _STLP_DFL_TMPL_PARAM(_Reference,_Tp&),
   170 # if defined (_STLP_MSVC50_COMPATIBILITY)
   171         _STLP_DFL_TMPL_PARAM(_Pointer, _Tp*),
   172 # endif
   173         _STLP_DFL_TYPE_PARAM(_Distance,ptrdiff_t)>
   174 class reverse_iterator {
   175   typedef reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>
   176           _Self;
   177 protected:
   178   _RandomAccessIterator __current;
   179 public:
   180   typedef random_access_iterator_tag iterator_category;
   181   typedef _Tp                        value_type;
   182   typedef _Distance                  difference_type;
   183 # if defined (_STLP_MSVC50_COMPATIBILITY)
   184   typedef _Pointer                   pointer;
   185 # else
   186   typedef _Tp*                       pointer;
   187 # endif
   188   typedef _Reference                 reference;
   189 
   190   reverse_iterator() {}
   191   reverse_iterator(const _Self& __x) : __current(__x.base()) {}
   192   explicit reverse_iterator(_RandomAccessIterator __x) : __current(__x) {}
   193   _Self& operator=(const _Self& __x) {__current = __x.base(); return *this; }
   194 
   195   _RandomAccessIterator base() const { return __current; }
   196   _Reference operator*() const { return *(__current - (difference_type)1); }
   197 
   198 # if !(defined _STLP_NO_ARROW_OPERATOR)
   199   _STLP_DEFINE_ARROW_OPERATOR
   200 # endif
   201 
   202   _Self& operator++() {
   203     --__current;
   204     return *this;
   205   }
   206   _Self operator++(int) {
   207     _Self __tmp = *this;
   208     --__current;
   209     return __tmp;
   210   }
   211   _Self& operator--() {
   212     ++__current;
   213     return *this;
   214   }
   215   _Self operator--(int) {
   216     _Self __tmp = *this;
   217     ++__current;
   218     return __tmp;
   219   }
   220   _Self operator+(_Distance __n) const {
   221     return _Self(__current - __n);
   222   }
   223   _Self& operator+=(_Distance __n) {
   224     __current -= __n;
   225     return *this;
   226   }
   227   _Self operator-(_Distance __n) const {
   228     return _Self(__current + __n);
   229   }
   230   _Self& operator-=(_Distance __n) {
   231     __current += __n;
   232     return *this;
   233   }
   234   _Reference operator[](_Distance __n) const { return *(*this + __n); }
   235 };
   236 
   237 # ifdef _STLP_USE_OLD_HP_ITERATOR_QUERIES
   238 template <class _RandomAccessIterator, class _Tp,
   239           class __Reference, class _Distance>
   240 inline random_access_iterator_tag _STLP_CALL
   241 iterator_category(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&)
   242 { return random_access_iterator_tag(); }
   243 template <class _RandomAccessIterator, class _Tp,
   244   class __Reference, class _Distance>
   245 inline _Tp*  _STLP_CALL value_type(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&)
   246 { return (_Tp*) 0; }
   247 template <class _RandomAccessIterator, class _Tp,
   248           class __Reference, class _Distance>
   249 inline _Distance*  _STLP_CALL
   250 distance_type(const reverse_iterator<_RandomAccessIterator, _Tp, Reference__, _Distance>&)
   251 { return (_Distance*) 0; }
   252 #endif
   253 
   254 template <class _RandomAccessIterator, class _Tp,
   255           class __Reference, class _Distance>
   256 inline bool  _STLP_CALL
   257 operator==(const reverse_iterator<_RandomAccessIterator, _Tp,
   258                                   Reference__, _Distance>& __x,
   259            const reverse_iterator<_RandomAccessIterator, _Tp,
   260                                   Reference__, _Distance>& __y)
   261 {
   262   return __x.base() == __y.base();
   263 }
   264 
   265 template <class _RandomAccessIterator, class _Tp,
   266           class __Reference, class _Distance>
   267 inline bool _STLP_CALL
   268 operator<(const reverse_iterator<_RandomAccessIterator, _Tp,
   269                                  Reference__, _Distance>& __x,
   270           const reverse_iterator<_RandomAccessIterator, _Tp,
   271                                  Reference__, _Distance>& __y)
   272 {
   273   return __y.base() < __x.base();
   274 }
   275 
   276 #ifdef _STLP_USE_SEPARATE_RELOPS_NAMESPACE
   277 
   278 template <class _RandomAccessIterator, class _Tp,
   279           class __Reference, class _Distance>
   280 inline bool _STLP_CALL
   281 operator!=(const reverse_iterator<_RandomAccessIterator, _Tp,
   282                                   Reference__, _Distance>& __x,
   283            const reverse_iterator<_RandomAccessIterator, _Tp,
   284                                   Reference__, _Distance>& __y) {
   285   return !(__x == __y);
   286 }
   287 
   288 template <class _RandomAccessIterator, class _Tp,
   289           class __Reference, class _Distance>
   290 inline bool _STLP_CALL
   291 operator>(const reverse_iterator<_RandomAccessIterator, _Tp,
   292                                  Reference__, _Distance>& __x,
   293           const reverse_iterator<_RandomAccessIterator, _Tp,
   294                                  Reference__, _Distance>& __y) {
   295   return __y < __x;
   296 }
   297 
   298 template <class _RandomAccessIterator, class _Tp,
   299           class __Reference, class _Distance>
   300 inline bool _STLP_CALL
   301 operator<=(const reverse_iterator<_RandomAccessIterator, _Tp,
   302                                   Reference__, _Distance>& __x,
   303            const reverse_iterator<_RandomAccessIterator, _Tp,
   304                                   Reference__, _Distance>& __y) {
   305   return !(__y < __x);
   306 }
   307 
   308 template <class _RandomAccessIterator, class _Tp,
   309           class __Reference, class _Distance>
   310 inline bool _STLP_CALL
   311 operator>=(const reverse_iterator<_RandomAccessIterator, _Tp,
   312                                   Reference__, _Distance>& __x,
   313            const reverse_iterator<_RandomAccessIterator, _Tp,
   314                                   Reference__, _Distance>& __y) {
   315   return !(__x < __y);
   316 }
   317 
   318 #endif /* _STLP_USE_SEPARATE_RELOPS_NAMESPACE */
   319 
   320 template <class _RandomAccessIterator, class _Tp,
   321           class __Reference, class _Distance>
   322 inline _Distance  _STLP_CALL
   323 operator-(const reverse_iterator<_RandomAccessIterator, _Tp,
   324                                  Reference__, _Distance>& __x,
   325           const reverse_iterator<_RandomAccessIterator, _Tp,
   326                                  Reference__, _Distance>& __y)
   327 {
   328   return __y.base() - __x.base();
   329 }
   330 
   331 template <class _RandomAccessIterator, class _Tp,
   332           class __Reference, class _Distance>
   333 inline reverse_iterator<_RandomAccessIterator, _Tp,
   334                         Reference__, _Distance>  _STLP_CALL
   335 operator+(_Distance __n,
   336           const reverse_iterator<_RandomAccessIterator, _Tp,
   337                                  Reference__, _Distance>& __x)
   338 {
   339   return reverse_iterator<_RandomAccessIterator, _Tp,
   340                           Reference__, _Distance>(__x.base() - __n);
   341 }
   342 
   343 #endif /* ! defined ( _STLP_CLASS_PARTIAL_SPECIALIZATION ) */
   344 
   345 _STLP_END_NAMESPACE
   346 
   347 #endif /* _STLP_INTERNAL_ITERATOR_H */
   348 
   349 // Local Variables:
   350 // mode:C++
   351 // End: