OSDN Git Service

2001-12-26 Benjamin Kosnik <bkoz@waller.constant.com>
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / include / bits / stl_iterator.h
index eb63892..5cfb579 100644 (file)
@@ -1,3 +1,32 @@
+// Iterators -*- C++ -*-
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
 /*
  *
  * Copyright (c) 1994
  * purpose.  It is provided "as is" without express or implied warranty.
  */
 
-/* NOTE: This is an internal header file, included by other STL headers.
- *   You should not attempt to use it directly.
+/** @file stl_iterator.h
+ *  This is an internal header file, included by other library headers.
+ *  You should not attempt to use it directly.
  */
 
-#ifndef __SGI_STL_INTERNAL_ITERATOR_H
-#define __SGI_STL_INTERNAL_ITERATOR_H
+#ifndef __GLIBCPP_INTERNAL_ITERATOR_H
+#define __GLIBCPP_INTERNAL_ITERATOR_H
 
 namespace std
 {
   // 24.4.1 Reverse iterators
   template<typename _Iterator>
     class reverse_iterator 
-      : public iterator<typename iterator_traits<_Iterator>::iterator_category,
-                       typename iterator_traits<_Iterator>::value_type,
-                       typename iterator_traits<_Iterator>::difference_type,
-                       typename iterator_traits<_Iterator>::pointer,
-                        typename iterator_traits<_Iterator>::reference>
+    : public iterator<typename iterator_traits<_Iterator>::iterator_category,
+                     typename iterator_traits<_Iterator>::value_type,
+                     typename iterator_traits<_Iterator>::difference_type,
+                     typename iterator_traits<_Iterator>::pointer,
+                      typename iterator_traits<_Iterator>::reference>
     {
     protected:
       _Iterator _M_current;
@@ -53,17 +83,17 @@ namespace std
       typedef typename iterator_traits<_Iterator>::pointer     pointer;
 
     public:
-      reverse_iterator() {}
+      reverse_iterator() { }
 
       explicit 
-      reverse_iterator(iterator_type __x) : _M_current(__x) {}
+      reverse_iterator(iterator_type __x) : _M_current(__x) { }
 
       reverse_iterator(const reverse_iterator& __x) 
-       : _M_current(__x._M_current) { }
+      : _M_current(__x._M_current) { }
 
       template<typename _Iter>
         reverse_iterator(const reverse_iterator<_Iter>& __x)
-       : _M_current(__x.base()) {}
+       : _M_current(__x.base()) { }
     
       iterator_type 
       base() const { return _M_current; }
@@ -183,22 +213,22 @@ namespace std
 
   // 24.4.2.2.1 back_insert_iterator
   template<typename _Container>
-  class back_insert_iterator 
+    class back_insert_iterator 
     : public iterator<output_iterator_tag, void, void, void, void>
     {
     protected:
-      _Container* container;
+      _Container* _M_container;
 
     public:
       typedef _Container          container_type;
       
       explicit 
-      back_insert_iterator(_Container& __x) : container(&__x) {}
+      back_insert_iterator(_Container& __x) : _M_container(&__x) { }
 
       back_insert_iterator&
-      operator=(const typename _Container::const_reference __value) 
+      operator=(typename _Container::const_reference __value) 
       { 
-       container->push_back(__value);
+       _M_container->push_back(__value);
        return *this;
       }
 
@@ -219,20 +249,20 @@ namespace std
 
   template<typename _Container>
     class front_insert_iterator 
-      : public iterator<output_iterator_tag, void, void, void, void>
+    : public iterator<output_iterator_tag, void, void, void, void>
     {
     protected:
-      _Container* container;
+      _Container* _M_container;
 
     public:
       typedef _Container          container_type;
 
-      explicit front_insert_iterator(_Container& __x) : container(&__x) {}
+      explicit front_insert_iterator(_Container& __x) : _M_container(&__x) { }
 
       front_insert_iterator&
-      operator=(const typename _Container::const_reference __value) 
+      operator=(typename _Container::const_reference __value) 
       { 
-       container->push_front(__value);
+       _M_container->push_front(__value);
        return *this;
       }
 
@@ -247,27 +277,28 @@ namespace std
     };
 
   template<typename _Container>
-  inline front_insert_iterator<_Container> front_inserter(_Container& __x) 
-  { return front_insert_iterator<_Container>(__x); }
+    inline front_insert_iterator<_Container> 
+    front_inserter(_Container& __x) 
+    { return front_insert_iterator<_Container>(__x); }
 
   template<typename _Container>
     class insert_iterator 
-      : public iterator<output_iterator_tag, void, void, void, void>
+    : public iterator<output_iterator_tag, void, void, void, void>
     {
     protected:
-      _Container* container;
+      _Container* _M_container;
       typename _Container::iterator iter;
 
     public:
       typedef _Container          container_type;
       
       insert_iterator(_Container& __x, typename _Container::iterator __i) 
-       : container(&__x), iter(__i) {}
+      : _M_container(&__x), iter(__i) {}
    
       insert_iterator&
       operator=(const typename _Container::const_reference __value) 
       { 
-       iter = container->insert(iter, __value);
+       iter = _M_container->insert(iter, __value);
        ++iter;
        return *this;
       }
@@ -283,15 +314,15 @@ namespace std
     };
   
   template<typename _Container, typename _Iterator>
-    inline 
-    insert_iterator<_Container> inserter(_Container& __x, _Iterator __i)
+    inline insert_iterator<_Container> 
+    inserter(_Container& __x, _Iterator __i)
     {
-      typedef typename _Container::iterator __iter;
-      return insert_iterator<_Container>(__x, __iter(__i));
+      return insert_iterator<_Container>(__x, 
+                                        typename _Container::iterator(__i));
     }
   
   // This iterator adapter is 'normal' in the sense that it does not
-  // change the semantics of any of the operators of its itererator
+  // change the semantics of any of the operators of its iterator
   // parameter.  Its primary purpose is to convert an iterator that is
   // not a class, e.g. a pointer, into an iterator that is a class.
   // The _Container parameter exists solely so that different containers
@@ -413,7 +444,7 @@ namespace std
 
   template<typename _Iterator, typename _Container>
   inline __normal_iterator<_Iterator, _Container>
-  operator+(__normal_iterator<_Iterator, _Container>::difference_type __n,
+  operator+(typename __normal_iterator<_Iterator, _Container>::difference_type __n,
            const __normal_iterator<_Iterator, _Container>& __i)
   { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
 } // namespace std