stl_iterator.h

Go to the documentation of this file.
00001 // Iterators -*- C++ -*-
00002 
00003 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
00004 // Free Software Foundation, Inc.
00005 //
00006 // This file is part of the GNU ISO C++ Library.  This library is free
00007 // software; you can redistribute it and/or modify it under the
00008 // terms of the GNU General Public License as published by the
00009 // Free Software Foundation; either version 2, or (at your option)
00010 // any later version.
00011 
00012 // This library is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 
00017 // You should have received a copy of the GNU General Public License along
00018 // with this library; see the file COPYING.  If not, write to the Free
00019 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00020 // USA.
00021 
00022 // As a special exception, you may use this file as part of a free software
00023 // library without restriction.  Specifically, if other files instantiate
00024 // templates or use macros or inline functions from this file, or you compile
00025 // this file and link it with other files to produce an executable, this
00026 // file does not by itself cause the resulting executable to be covered by
00027 // the GNU General Public License.  This exception does not however
00028 // invalidate any other reasons why the executable file might be covered by
00029 // the GNU General Public License.
00030 
00031 /*
00032  *
00033  * Copyright (c) 1994
00034  * Hewlett-Packard Company
00035  *
00036  * Permission to use, copy, modify, distribute and sell this software
00037  * and its documentation for any purpose is hereby granted without fee,
00038  * provided that the above copyright notice appear in all copies and
00039  * that both that copyright notice and this permission notice appear
00040  * in supporting documentation.  Hewlett-Packard Company makes no
00041  * representations about the suitability of this software for any
00042  * purpose.  It is provided "as is" without express or implied warranty.
00043  *
00044  *
00045  * Copyright (c) 1996-1998
00046  * Silicon Graphics Computer Systems, Inc.
00047  *
00048  * Permission to use, copy, modify, distribute and sell this software
00049  * and its documentation for any purpose is hereby granted without fee,
00050  * provided that the above copyright notice appear in all copies and
00051  * that both that copyright notice and this permission notice appear
00052  * in supporting documentation.  Silicon Graphics makes no
00053  * representations about the suitability of this software for any
00054  * purpose.  It is provided "as is" without express or implied warranty.
00055  */
00056 
00057 /** @file stl_iterator.h
00058  *  This is an internal header file, included by other library headers.
00059  *  You should not attempt to use it directly.
00060  *
00061  *  This file implements reverse_iterator, back_insert_iterator,
00062  *  front_insert_iterator, insert_iterator, __normal_iterator, and their
00063  *  supporting functions and overloaded operators.
00064  */
00065 
00066 #ifndef _ITERATOR_H
00067 #define _ITERATOR_H 1
00068 
00069 #include <bits/cpp_type_traits.h>
00070 #include <ext/type_traits.h>
00071 
00072 _GLIBCXX_BEGIN_NAMESPACE(std)
00073 
00074   // 24.4.1 Reverse iterators
00075   /**
00076    *  "Bidirectional and random access iterators have corresponding reverse
00077    *  %iterator adaptors that iterate through the data structure in the
00078    *  opposite direction.  They have the same signatures as the corresponding
00079    *  iterators.  The fundamental relation between a reverse %iterator and its
00080    *  corresponding %iterator @c i is established by the identity:
00081    *  @code
00082    *      &*(reverse_iterator(i)) == &*(i - 1)
00083    *  @endcode
00084    *
00085    *  This mapping is dictated by the fact that while there is always a
00086    *  pointer past the end of an array, there might not be a valid pointer
00087    *  before the beginning of an array." [24.4.1]/1,2
00088    *
00089    *  Reverse iterators can be tricky and surprising at first.  Their
00090    *  semantics make sense, however, and the trickiness is a side effect of
00091    *  the requirement that the iterators must be safe.
00092   */
00093   template<typename _Iterator>
00094     class reverse_iterator
00095     : public iterator<typename iterator_traits<_Iterator>::iterator_category,
00096               typename iterator_traits<_Iterator>::value_type,
00097               typename iterator_traits<_Iterator>::difference_type,
00098               typename iterator_traits<_Iterator>::pointer,
00099                       typename iterator_traits<_Iterator>::reference>
00100     {
00101     protected:
00102       _Iterator current;
00103 
00104     public:
00105       typedef _Iterator                        iterator_type;
00106       typedef typename iterator_traits<_Iterator>::difference_type
00107                                    difference_type;
00108       typedef typename iterator_traits<_Iterator>::reference   reference;
00109       typedef typename iterator_traits<_Iterator>::pointer     pointer;
00110 
00111     public:
00112       /**
00113        *  The default constructor default-initializes member @p current.
00114        *  If it is a pointer, that means it is zero-initialized.
00115       */
00116       // _GLIBCXX_RESOLVE_LIB_DEFECTS
00117       // 235 No specification of default ctor for reverse_iterator
00118       reverse_iterator() : current() { }
00119 
00120       /**
00121        *  This %iterator will move in the opposite direction that @p x does.
00122       */
00123       explicit
00124       reverse_iterator(iterator_type __x) : current(__x) { }
00125 
00126       /**
00127        *  The copy constructor is normal.
00128       */
00129       reverse_iterator(const reverse_iterator& __x)
00130       : current(__x.current) { }
00131 
00132       /**
00133        *  A reverse_iterator across other types can be copied in the normal
00134        *  fashion.
00135       */
00136       template<typename _Iter>
00137         reverse_iterator(const reverse_iterator<_Iter>& __x)
00138     : current(__x.base()) { }
00139 
00140       /**
00141        *  @return  @c current, the %iterator used for underlying work.
00142       */
00143       iterator_type
00144       base() const
00145       { return current; }
00146 
00147       /**
00148        *  @return  TODO
00149        *
00150        *  @doctodo
00151       */
00152       reference
00153       operator*() const
00154       {
00155     _Iterator __tmp = current;
00156     return *--__tmp;
00157       }
00158 
00159       /**
00160        *  @return  TODO
00161        *
00162        *  @doctodo
00163       */
00164       pointer
00165       operator->() const
00166       { return &(operator*()); }
00167 
00168       /**
00169        *  @return  TODO
00170        *
00171        *  @doctodo
00172       */
00173       reverse_iterator&
00174       operator++()
00175       {
00176     --current;
00177     return *this;
00178       }
00179 
00180       /**
00181        *  @return  TODO
00182        *
00183        *  @doctodo
00184       */
00185       reverse_iterator
00186       operator++(int)
00187       {
00188     reverse_iterator __tmp = *this;
00189     --current;
00190     return __tmp;
00191       }
00192 
00193       /**
00194        *  @return  TODO
00195        *
00196        *  @doctodo
00197       */
00198       reverse_iterator&
00199       operator--()
00200       {
00201     ++current;
00202     return *this;
00203       }
00204 
00205       /**
00206        *  @return  TODO
00207        *
00208        *  @doctodo
00209       */
00210       reverse_iterator
00211       operator--(int)
00212       {
00213     reverse_iterator __tmp = *this;
00214     ++current;
00215     return __tmp;
00216       }
00217 
00218       /**
00219        *  @return  TODO
00220        *
00221        *  @doctodo
00222       */
00223       reverse_iterator
00224       operator+(difference_type __n) const
00225       { return reverse_iterator(current - __n); }
00226 
00227       /**
00228        *  @return  TODO
00229        *
00230        *  @doctodo
00231       */
00232       reverse_iterator&
00233       operator+=(difference_type __n)
00234       {
00235     current -= __n;
00236     return *this;
00237       }
00238 
00239       /**
00240        *  @return  TODO
00241        *
00242        *  @doctodo
00243       */
00244       reverse_iterator
00245       operator-(difference_type __n) const
00246       { return reverse_iterator(current + __n); }
00247 
00248       /**
00249        *  @return  TODO
00250        *
00251        *  @doctodo
00252       */
00253       reverse_iterator&
00254       operator-=(difference_type __n)
00255       {
00256     current += __n;
00257     return *this;
00258       }
00259 
00260       /**
00261        *  @return  TODO
00262        *
00263        *  @doctodo
00264       */
00265       reference
00266       operator[](difference_type __n) const
00267       { return *(*this + __n); }
00268     };
00269 
00270   //@{
00271   /**
00272    *  @param  x  A %reverse_iterator.
00273    *  @param  y  A %reverse_iterator.
00274    *  @return  A simple bool.
00275    *
00276    *  Reverse iterators forward many operations to their underlying base()
00277    *  iterators.  Others are implemented in terms of one another.
00278    *
00279   */
00280   template<typename _Iterator>
00281     inline bool
00282     operator==(const reverse_iterator<_Iterator>& __x,
00283            const reverse_iterator<_Iterator>& __y)
00284     { return __x.base() == __y.base(); }
00285 
00286   template<typename _Iterator>
00287     inline bool
00288     operator<(const reverse_iterator<_Iterator>& __x,
00289           const reverse_iterator<_Iterator>& __y)
00290     { return __y.base() < __x.base(); }
00291 
00292   template<typename _Iterator>
00293     inline bool
00294     operator!=(const reverse_iterator<_Iterator>& __x,
00295            const reverse_iterator<_Iterator>& __y)
00296     { return !(__x == __y); }
00297 
00298   template<typename _Iterator>
00299     inline bool
00300     operator>(const reverse_iterator<_Iterator>& __x,
00301           const reverse_iterator<_Iterator>& __y)
00302     { return __y < __x; }
00303 
00304   template<typename _Iterator>
00305     inline bool
00306     operator<=(const reverse_iterator<_Iterator>& __x,
00307            const reverse_iterator<_Iterator>& __y)
00308     { return !(__y < __x); }
00309 
00310   template<typename _Iterator>
00311     inline bool
00312     operator>=(const reverse_iterator<_Iterator>& __x,
00313            const reverse_iterator<_Iterator>& __y)
00314     { return !(__x < __y); }
00315 
00316   template<typename _Iterator>
00317     inline typename reverse_iterator<_Iterator>::difference_type
00318     operator-(const reverse_iterator<_Iterator>& __x,
00319           const reverse_iterator<_Iterator>& __y)
00320     { return __y.base() - __x.base(); }
00321 
00322   template<typename _Iterator>
00323     inline reverse_iterator<_Iterator>
00324     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
00325           const reverse_iterator<_Iterator>& __x)
00326     { return reverse_iterator<_Iterator>(__x.base() - __n); }
00327 
00328   // _GLIBCXX_RESOLVE_LIB_DEFECTS
00329   // DR 280. Comparison of reverse_iterator to const reverse_iterator.
00330   template<typename _IteratorL, typename _IteratorR>
00331     inline bool
00332     operator==(const reverse_iterator<_IteratorL>& __x,
00333            const reverse_iterator<_IteratorR>& __y)
00334     { return __x.base() == __y.base(); }
00335 
00336   template<typename _IteratorL, typename _IteratorR>
00337     inline bool
00338     operator<(const reverse_iterator<_IteratorL>& __x,
00339           const reverse_iterator<_IteratorR>& __y)
00340     { return __y.base() < __x.base(); }
00341 
00342   template<typename _IteratorL, typename _IteratorR>
00343     inline bool
00344     operator!=(const reverse_iterator<_IteratorL>& __x,
00345            const reverse_iterator<_IteratorR>& __y)
00346     { return !(__x == __y); }
00347 
00348   template<typename _IteratorL, typename _IteratorR>
00349     inline bool
00350     operator>(const reverse_iterator<_IteratorL>& __x,
00351           const reverse_iterator<_IteratorR>& __y)
00352     { return __y < __x; }
00353 
00354   template<typename _IteratorL, typename _IteratorR>
00355     inline bool
00356     operator<=(const reverse_iterator<_IteratorL>& __x,
00357            const reverse_iterator<_IteratorR>& __y)
00358     { return !(__y < __x); }
00359 
00360   template<typename _IteratorL, typename _IteratorR>
00361     inline bool
00362     operator>=(const reverse_iterator<_IteratorL>& __x,
00363            const reverse_iterator<_IteratorR>& __y)
00364     { return !(__x < __y); }
00365 
00366   template<typename _IteratorL, typename _IteratorR>
00367     inline typename reverse_iterator<_IteratorL>::difference_type
00368     operator-(const reverse_iterator<_IteratorL>& __x,
00369           const reverse_iterator<_IteratorR>& __y)
00370     { return __y.base() - __x.base(); }
00371   //@}
00372 
00373   // 24.4.2.2.1 back_insert_iterator
00374   /**
00375    *  @brief  Turns assignment into insertion.
00376    *
00377    *  These are output iterators, constructed from a container-of-T.
00378    *  Assigning a T to the iterator appends it to the container using
00379    *  push_back.
00380    *
00381    *  Tip:  Using the back_inserter function to create these iterators can
00382    *  save typing.
00383   */
00384   template<typename _Container>
00385     class back_insert_iterator
00386     : public iterator<output_iterator_tag, void, void, void, void>
00387     {
00388     protected:
00389       _Container* container;
00390 
00391     public:
00392       /// A nested typedef for the type of whatever container you used.
00393       typedef _Container          container_type;
00394 
00395       /// The only way to create this %iterator is with a container.
00396       explicit
00397       back_insert_iterator(_Container& __x) : container(&__x) { }
00398 
00399       /**
00400        *  @param  value  An instance of whatever type
00401        *                 container_type::const_reference is; presumably a
00402        *                 reference-to-const T for container<T>.
00403        *  @return  This %iterator, for chained operations.
00404        *
00405        *  This kind of %iterator doesn't really have a "position" in the
00406        *  container (you can think of the position as being permanently at
00407        *  the end, if you like).  Assigning a value to the %iterator will
00408        *  always append the value to the end of the container.
00409       */
00410       back_insert_iterator&
00411       operator=(typename _Container::const_reference __value)
00412       {
00413     container->push_back(__value);
00414     return *this;
00415       }
00416 
00417       /// Simply returns *this.
00418       back_insert_iterator&
00419       operator*()
00420       { return *this; }
00421 
00422       /// Simply returns *this.  (This %iterator does not "move".)
00423       back_insert_iterator&
00424       operator++()
00425       { return *this; }
00426 
00427       /// Simply returns *this.  (This %iterator does not "move".)
00428       back_insert_iterator
00429       operator++(int)
00430       { return *this; }
00431     };
00432 
00433   /**
00434    *  @param  x  A container of arbitrary type.
00435    *  @return  An instance of back_insert_iterator working on @p x.
00436    *
00437    *  This wrapper function helps in creating back_insert_iterator instances.
00438    *  Typing the name of the %iterator requires knowing the precise full
00439    *  type of the container, which can be tedious and impedes generic
00440    *  programming.  Using this function lets you take advantage of automatic
00441    *  template parameter deduction, making the compiler match the correct
00442    *  types for you.
00443   */
00444   template<typename _Container>
00445     inline back_insert_iterator<_Container>
00446     back_inserter(_Container& __x)
00447     { return back_insert_iterator<_Container>(__x); }
00448 
00449   /**
00450    *  @brief  Turns assignment into insertion.
00451    *
00452    *  These are output iterators, constructed from a container-of-T.
00453    *  Assigning a T to the iterator prepends it to the container using
00454    *  push_front.
00455    *
00456    *  Tip:  Using the front_inserter function to create these iterators can
00457    *  save typing.
00458   */
00459   template<typename _Container>
00460     class front_insert_iterator
00461     : public iterator<output_iterator_tag, void, void, void, void>
00462     {
00463     protected:
00464       _Container* container;
00465 
00466     public:
00467       /// A nested typedef for the type of whatever container you used.
00468       typedef _Container          container_type;
00469 
00470       /// The only way to create this %iterator is with a container.
00471       explicit front_insert_iterator(_Container& __x) : container(&__x) { }
00472 
00473       /**
00474        *  @param  value  An instance of whatever type
00475        *                 container_type::const_reference is; presumably a
00476        *                 reference-to-const T for container<T>.
00477        *  @return  This %iterator, for chained operations.
00478        *
00479        *  This kind of %iterator doesn't really have a "position" in the
00480        *  container (you can think of the position as being permanently at
00481        *  the front, if you like).  Assigning a value to the %iterator will
00482        *  always prepend the value to the front of the container.
00483       */
00484       front_insert_iterator&
00485       operator=(typename _Container::const_reference __value)
00486       {
00487     container->push_front(__value);
00488     return *this;
00489       }
00490 
00491       /// Simply returns *this.
00492       front_insert_iterator&
00493       operator*()
00494       { return *this; }
00495 
00496       /// Simply returns *this.  (This %iterator does not "move".)
00497       front_insert_iterator&
00498       operator++()
00499       { return *this; }
00500 
00501       /// Simply returns *this.  (This %iterator does not "move".)
00502       front_insert_iterator
00503       operator++(int)
00504       { return *this; }
00505     };
00506 
00507   /**
00508    *  @param  x  A container of arbitrary type.
00509    *  @return  An instance of front_insert_iterator working on @p x.
00510    *
00511    *  This wrapper function helps in creating front_insert_iterator instances.
00512    *  Typing the name of the %iterator requires knowing the precise full
00513    *  type of the container, which can be tedious and impedes generic
00514    *  programming.  Using this function lets you take advantage of automatic
00515    *  template parameter deduction, making the compiler match the correct
00516    *  types for you.
00517   */
00518   template<typename _Container>
00519     inline front_insert_iterator<_Container>
00520     front_inserter(_Container& __x)
00521     { return front_insert_iterator<_Container>(__x); }
00522 
00523   /**
00524    *  @brief  Turns assignment into insertion.
00525    *
00526    *  These are output iterators, constructed from a container-of-T.
00527    *  Assigning a T to the iterator inserts it in the container at the
00528    *  %iterator's position, rather than overwriting the value at that
00529    *  position.
00530    *
00531    *  (Sequences will actually insert a @e copy of the value before the
00532    *  %iterator's position.)
00533    *
00534    *  Tip:  Using the inserter function to create these iterators can
00535    *  save typing.
00536   */
00537   template<typename _Container>
00538     class insert_iterator
00539     : public iterator<output_iterator_tag, void, void, void, void>
00540     {
00541     protected:
00542       _Container* container;
00543       typename _Container::iterator iter;
00544 
00545     public:
00546       /// A nested typedef for the type of whatever container you used.
00547       typedef _Container          container_type;
00548 
00549       /**
00550        *  The only way to create this %iterator is with a container and an
00551        *  initial position (a normal %iterator into the container).
00552       */
00553       insert_iterator(_Container& __x, typename _Container::iterator __i)
00554       : container(&__x), iter(__i) {}
00555 
00556       /**
00557        *  @param  value  An instance of whatever type
00558        *                 container_type::const_reference is; presumably a
00559        *                 reference-to-const T for container<T>.
00560        *  @return  This %iterator, for chained operations.
00561        *
00562        *  This kind of %iterator maintains its own position in the
00563        *  container.  Assigning a value to the %iterator will insert the
00564        *  value into the container at the place before the %iterator.
00565        *
00566        *  The position is maintained such that subsequent assignments will
00567        *  insert values immediately after one another.  For example,
00568        *  @code
00569        *     // vector v contains A and Z
00570        *
00571        *     insert_iterator i (v, ++v.begin());
00572        *     i = 1;
00573        *     i = 2;
00574        *     i = 3;
00575        *
00576        *     // vector v contains A, 1, 2, 3, and Z
00577        *  @endcode
00578       */
00579       insert_iterator&
00580       operator=(const typename _Container::const_reference __value)
00581       {
00582     iter = container->insert(iter, __value);
00583     ++iter;
00584     return *this;
00585       }
00586 
00587       /// Simply returns *this.
00588       insert_iterator&
00589       operator*()
00590       { return *this; }
00591 
00592       /// Simply returns *this.  (This %iterator does not "move".)
00593       insert_iterator&
00594       operator++()
00595       { return *this; }
00596 
00597       /// Simply returns *this.  (This %iterator does not "move".)
00598       insert_iterator&
00599       operator++(int)
00600       { return *this; }
00601     };
00602 
00603   /**
00604    *  @param  x  A container of arbitrary type.
00605    *  @return  An instance of insert_iterator working on @p x.
00606    *
00607    *  This wrapper function helps in creating insert_iterator instances.
00608    *  Typing the name of the %iterator requires knowing the precise full
00609    *  type of the container, which can be tedious and impedes generic
00610    *  programming.  Using this function lets you take advantage of automatic
00611    *  template parameter deduction, making the compiler match the correct
00612    *  types for you.
00613   */
00614   template<typename _Container, typename _Iterator>
00615     inline insert_iterator<_Container>
00616     inserter(_Container& __x, _Iterator __i)
00617     {
00618       return insert_iterator<_Container>(__x,
00619                      typename _Container::iterator(__i));
00620     }
00621 
00622 _GLIBCXX_END_NAMESPACE
00623 
00624 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
00625 
00626   // This iterator adapter is 'normal' in the sense that it does not
00627   // change the semantics of any of the operators of its iterator
00628   // parameter.  Its primary purpose is to convert an iterator that is
00629   // not a class, e.g. a pointer, into an iterator that is a class.
00630   // The _Container parameter exists solely so that different containers
00631   // using this template can instantiate different types, even if the
00632   // _Iterator parameter is the same.
00633   using std::iterator_traits;
00634   using std::iterator;
00635   template<typename _Iterator, typename _Container>
00636     class __normal_iterator
00637     {
00638     protected:
00639       _Iterator _M_current;
00640 
00641     public:
00642       typedef typename iterator_traits<_Iterator>::iterator_category
00643                                                              iterator_category;
00644       typedef typename iterator_traits<_Iterator>::value_type  value_type;
00645       typedef typename iterator_traits<_Iterator>::difference_type
00646                                                              difference_type;
00647       typedef typename iterator_traits<_Iterator>::reference reference;
00648       typedef typename iterator_traits<_Iterator>::pointer   pointer;
00649 
00650       __normal_iterator() : _M_current(_Iterator()) { }
00651 
00652       explicit
00653       __normal_iterator(const _Iterator& __i) : _M_current(__i) { }
00654 
00655       // Allow iterator to const_iterator conversion
00656       template<typename _Iter>
00657         __normal_iterator(const __normal_iterator<_Iter,
00658               typename __enable_if<
00659                (std::__are_same<_Iter, typename _Container::pointer>::__value),
00660               _Container>::__type>& __i)
00661         : _M_current(__i.base()) { }
00662 
00663       // Forward iterator requirements
00664       reference
00665       operator*() const
00666       { return *_M_current; }
00667 
00668       pointer
00669       operator->() const
00670       { return _M_current; }
00671 
00672       __normal_iterator&
00673       operator++()
00674       {
00675     ++_M_current;
00676     return *this;
00677       }
00678 
00679       __normal_iterator
00680       operator++(int)
00681       { return __normal_iterator(_M_current++); }
00682 
00683       // Bidirectional iterator requirements
00684       __normal_iterator&
00685       operator--()
00686       {
00687     --_M_current;
00688     return *this;
00689       }
00690 
00691       __normal_iterator
00692       operator--(int)
00693       { return __normal_iterator(_M_current--); }
00694 
00695       // Random access iterator requirements
00696       reference
00697       operator[](const difference_type& __n) const
00698       { return _M_current[__n]; }
00699 
00700       __normal_iterator&
00701       operator+=(const difference_type& __n)
00702       { _M_current += __n; return *this; }
00703 
00704       __normal_iterator
00705       operator+(const difference_type& __n) const
00706       { return __normal_iterator(_M_current + __n); }
00707 
00708       __normal_iterator&
00709       operator-=(const difference_type& __n)
00710       { _M_current -= __n; return *this; }
00711 
00712       __normal_iterator
00713       operator-(const difference_type& __n) const
00714       { return __normal_iterator(_M_current - __n); }
00715 
00716       const _Iterator&
00717       base() const
00718       { return _M_current; }
00719     };
00720 
00721   // Note: In what follows, the left- and right-hand-side iterators are
00722   // allowed to vary in types (conceptually in cv-qualification) so that
00723   // comparaison between cv-qualified and non-cv-qualified iterators be
00724   // valid.  However, the greedy and unfriendly operators in std::rel_ops
00725   // will make overload resolution ambiguous (when in scope) if we don't
00726   // provide overloads whose operands are of the same type.  Can someone
00727   // remind me what generic programming is about? -- Gaby
00728 
00729   // Forward iterator requirements
00730   template<typename _IteratorL, typename _IteratorR, typename _Container>
00731     inline bool
00732     operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
00733            const __normal_iterator<_IteratorR, _Container>& __rhs)
00734     { return __lhs.base() == __rhs.base(); }
00735 
00736   template<typename _Iterator, typename _Container>
00737     inline bool
00738     operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
00739            const __normal_iterator<_Iterator, _Container>& __rhs)
00740     { return __lhs.base() == __rhs.base(); }
00741 
00742   template<typename _IteratorL, typename _IteratorR, typename _Container>
00743     inline bool
00744     operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
00745            const __normal_iterator<_IteratorR, _Container>& __rhs)
00746     { return __lhs.base() != __rhs.base(); }
00747 
00748   template<typename _Iterator, typename _Container>
00749     inline bool
00750     operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
00751            const __normal_iterator<_Iterator, _Container>& __rhs)
00752     { return __lhs.base() != __rhs.base(); }
00753 
00754   // Random access iterator requirements
00755   template<typename _IteratorL, typename _IteratorR, typename _Container>
00756     inline bool
00757     operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
00758           const __normal_iterator<_IteratorR, _Container>& __rhs)
00759     { return __lhs.base() < __rhs.base(); }
00760 
00761   template<typename _Iterator, typename _Container>
00762     inline bool
00763     operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
00764           const __normal_iterator<_Iterator, _Container>& __rhs)
00765     { return __lhs.base() < __rhs.base(); }
00766 
00767   template<typename _IteratorL, typename _IteratorR, typename _Container>
00768     inline bool
00769     operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
00770           const __normal_iterator<_IteratorR, _Container>& __rhs)
00771     { return __lhs.base() > __rhs.base(); }
00772 
00773   template<typename _Iterator, typename _Container>
00774     inline bool
00775     operator>(const __normal_iterator<_Iterator, _Container>& __lhs,
00776           const __normal_iterator<_Iterator, _Container>& __rhs)
00777     { return __lhs.base() > __rhs.base(); }
00778 
00779   template<typename _IteratorL, typename _IteratorR, typename _Container>
00780     inline bool
00781     operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
00782            const __normal_iterator<_IteratorR, _Container>& __rhs)
00783     { return __lhs.base() <= __rhs.base(); }
00784 
00785   template<typename _Iterator, typename _Container>
00786     inline bool
00787     operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
00788            const __normal_iterator<_Iterator, _Container>& __rhs)
00789     { return __lhs.base() <= __rhs.base(); }
00790 
00791   template<typename _IteratorL, typename _IteratorR, typename _Container>
00792     inline bool
00793     operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
00794            const __normal_iterator<_IteratorR, _Container>& __rhs)
00795     { return __lhs.base() >= __rhs.base(); }
00796 
00797   template<typename _Iterator, typename _Container>
00798     inline bool
00799     operator>=(const __normal_iterator<_Iterator, _Container>& __lhs,
00800            const __normal_iterator<_Iterator, _Container>& __rhs)
00801     { return __lhs.base() >= __rhs.base(); }
00802 
00803   // _GLIBCXX_RESOLVE_LIB_DEFECTS
00804   // According to the resolution of DR179 not only the various comparison
00805   // operators but also operator- must accept mixed iterator/const_iterator
00806   // parameters.
00807   template<typename _IteratorL, typename _IteratorR, typename _Container>
00808     inline typename __normal_iterator<_IteratorL, _Container>::difference_type
00809     operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
00810           const __normal_iterator<_IteratorR, _Container>& __rhs)
00811     { return __lhs.base() - __rhs.base(); }
00812 
00813   template<typename _Iterator, typename _Container>
00814     inline typename __normal_iterator<_Iterator, _Container>::difference_type
00815     operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
00816           const __normal_iterator<_Iterator, _Container>& __rhs)
00817     { return __lhs.base() - __rhs.base(); }
00818 
00819   template<typename _Iterator, typename _Container>
00820     inline __normal_iterator<_Iterator, _Container>
00821     operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
00822           __n, const __normal_iterator<_Iterator, _Container>& __i)
00823     { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
00824 
00825 _GLIBCXX_END_NAMESPACE
00826 
00827 #endif

Generated on Thu Nov 1 13:12:32 2007 for libstdc++ by  doxygen 1.5.1