stl_iterator.h (reverse_iterator): Inherit from iterator.
authorBenjamin Kosnik <bkoz@redhat.com>
Sat, 23 Jun 2001 00:08:47 +0000 (00:08 +0000)
committerBenjamin Kosnik <bkoz@gcc.gnu.org>
Sat, 23 Jun 2001 00:08:47 +0000 (00:08 +0000)
2001-06-22  Benjamin Kosnik  <bkoz@redhat.com>

* include/bits/stl_iterator.h (reverse_iterator): Inherit from
iterator.
(back_insert_iterator): Same.
(front_insert_iterator): Same.
(insert_iterator): Same.

* testsuite/20_util/raw_storage_iterator.cc: Modify.
* testsuite/24_iterators/reverse_iterator.cc: New file.
* testsuite/24_iterators/back_insert_iterator.cc: New file.
* testsuite/24_iterators/front_insert_iterator.cc: New file.
* testsuite/24_iterators/insert_iterator.cc: New file.

From-SVN: r43524

libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/stl_iterator.h
libstdc++-v3/testsuite/20_util/raw_storage_iterator.cc
libstdc++-v3/testsuite/24_iterators/back_insert_iterator.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/front_insert_iterator.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/insert_iterator.cc [new file with mode: 0644]
libstdc++-v3/testsuite/24_iterators/reverse_iterator.cc [new file with mode: 0644]

index c8e5f2147e44e56861e83992f67c0baa35a4ea90..9623194beb496c3aa5ae219910c3559dfd8326bd 100644 (file)
@@ -1,3 +1,17 @@
+2001-06-22  Benjamin Kosnik  <bkoz@redhat.com>
+
+       * include/bits/stl_iterator.h (reverse_iterator): Inherit from
+       iterator.
+       (back_insert_iterator): Same.   
+       (front_insert_iterator): Same.
+       (insert_iterator): Same.
+
+       * testsuite/20_util/raw_storage_iterator.cc: Modify.
+       * testsuite/24_iterators/reverse_iterator.cc: New file.
+       * testsuite/24_iterators/back_insert_iterator.cc: New file.
+       * testsuite/24_iterators/front_insert_iterator.cc: New file.
+       * testsuite/24_iterators/insert_iterator.cc: New file.
+
 2001-06-22  Phil Edwards  <pme@sources.redhat.com>
 
        * include/*:  Revert comment/license change from yesterday for all
index a062d4dcb016a23ccfc42830f494a01b9d40bdc8..148cad6a1847f2a736adf510c4d159742f6c3641 100644 (file)
 
 namespace std
 {
-
-template <class _Container>
-class back_insert_iterator {
-protected:
-  _Container* container;
-public:
-  typedef _Container          container_type;
-  typedef output_iterator_tag iterator_category;
-  typedef void                value_type;
-  typedef void                difference_type;
-  typedef void                pointer;
-  typedef void                reference;
-
-  explicit back_insert_iterator(_Container& __x) : container(&__x) {}
-  back_insert_iterator<_Container>&
-  operator=(const typename _Container::value_type& __value) { 
-    container->push_back(__value);
-    return *this;
-  }
-  back_insert_iterator<_Container>& operator*() { return *this; }
-  back_insert_iterator<_Container>& operator++() { return *this; }
-  back_insert_iterator<_Container>& operator++(int) { return *this; }
-};
-
-template <class _Container>
-inline back_insert_iterator<_Container> back_inserter(_Container& __x) {
-  return back_insert_iterator<_Container>(__x);
-}
-
-template <class _Container>
-class front_insert_iterator {
-protected:
-  _Container* container;
-public:
-  typedef _Container          container_type;
-  typedef output_iterator_tag iterator_category;
-  typedef void                value_type;
-  typedef void                difference_type;
-  typedef void                pointer;
-  typedef void                reference;
-
-  explicit front_insert_iterator(_Container& __x) : container(&__x) {}
-  front_insert_iterator<_Container>&
-  operator=(const typename _Container::value_type& __value) { 
-    container->push_front(__value);
-    return *this;
+  // 24.4.1 Reverse iterators
+  template<class _Iterator>
+    class reverse_iterator 
+      : public iterator<iterator_traits<_Iterator>::iterator_category,
+                       iterator_traits<_Iterator>::value_type,
+                       iterator_traits<_Iterator>::difference_type,
+                       iterator_traits<_Iterator>::pointer,
+                        iterator_traits<_Iterator>::reference>
+    {
+    protected:
+      _Iterator current;
+
+    public:
+      typedef iterator_traits<_Iterator>               __traits_type;
+      typedef typename __traits_type::iterator_category        iterator_category;
+      typedef typename __traits_type::value_type       value_type;
+      typedef typename __traits_type::difference_type  difference_type;
+      typedef typename __traits_type::pointer                  pointer;
+      typedef typename __traits_type::reference        reference;
+
+      typedef _Iterator iterator_type;
+      typedef reverse_iterator<_Iterator> _Self;
+
+    public:
+      reverse_iterator() {}
+
+      explicit 
+      reverse_iterator(iterator_type __x) : current(__x) {}
+
+      reverse_iterator(const _Self& __x) : current(__x.current) {}
+
+      template <class _Iter>
+        reverse_iterator(const reverse_iterator<_Iter>& __x)
+       : current(__x.base()) {}
+    
+      iterator_type 
+      base() const { return current; }
+
+      reference 
+      operator*() const 
+      {
+       _Iterator __tmp = current;
+       return *--__tmp;
+      }
+
+      pointer 
+      operator->() const { return &(operator*()); }
+
+      _Self& 
+      operator++() 
+      {
+       --current;
+       return *this;
+      }
+
+      _Self 
+      operator++(int) 
+      {
+       _Self __tmp = *this;
+       --current;
+       return __tmp;
+      }
+
+      _Self& 
+      operator--() 
+      {
+       ++current;
+       return *this;
+      }
+
+      _Self operator--(int) 
+      {
+       _Self __tmp = *this;
+       ++current;
+       return __tmp;
+      }
+      
+      _Self 
+      operator+(difference_type __n) const 
+      { return _Self(current - __n); }
+
+      _Self& 
+      operator+=(difference_type __n) 
+      {
+       current -= __n;
+       return *this;
+      }
+
+      _Self 
+      operator-(difference_type __n) const 
+      { return _Self(current + __n); }
+
+      _Self& 
+      operator-=(difference_type __n) 
+      {
+       current += __n;
+       return *this;
+      }
+
+      reference 
+      operator[](difference_type __n) const { return *(*this + __n); }  
+    }; 
+  template<class _Iterator>
+    inline bool 
+    operator==(const reverse_iterator<_Iterator>& __x, 
+              const reverse_iterator<_Iterator>& __y) 
+    { return __x.base() == __y.base(); }
+
+  template <class _Iterator>
+    inline bool 
+    operator<(const reverse_iterator<_Iterator>& __x, 
+             const reverse_iterator<_Iterator>& __y) 
+    { return __y.base() < __x.base(); }
+
+  template <class _Iterator>
+    inline bool 
+    operator!=(const reverse_iterator<_Iterator>& __x, 
+              const reverse_iterator<_Iterator>& __y) 
+    { return !(__x == __y); }
+
+  template <class _Iterator>
+    inline bool 
+    operator>(const reverse_iterator<_Iterator>& __x, 
+             const reverse_iterator<_Iterator>& __y) 
+    { return __y < __x; }
+
+  template <class _Iterator>
+    inline bool 
+    operator<=(const reverse_iterator<_Iterator>& __x, 
+               const reverse_iterator<_Iterator>& __y) 
+    { return !(__y < __x); }
+
+  template <class _Iterator>
+    inline bool 
+    operator>=(const reverse_iterator<_Iterator>& __x, 
+              const reverse_iterator<_Iterator>& __y) 
+    { return !(__x < __y); }
+
+  template<class _Iterator>
+    inline typename reverse_iterator<_Iterator>::difference_type
+    operator-(const reverse_iterator<_Iterator>& __x, 
+             const reverse_iterator<_Iterator>& __y) 
+    { return __y.base() - __x.base(); }
+
+  template <class _Iterator>
+    inline reverse_iterator<_Iterator> 
+    operator+(typename reverse_iterator<_Iterator>::difference_type __n,
+             const reverse_iterator<_Iterator>& __x) 
+    { return reverse_iterator<_Iterator>(__x.base() - __n); }
+
+  // 24.4.2.2.1 back_insert_iterator
+  template <class _Container>
+  class back_insert_iterator 
+    : public iterator<output_iterator_tag, void, void, void, void>
+    {
+    protected:
+      _Container* container;
+
+    public:
+      typedef _Container          container_type;
+      
+      explicit 
+      back_insert_iterator(_Container& __x) : container(&__x) {}
+
+      back_insert_iterator<_Container>&
+      operator=(const typename _Container::value_type& __value) 
+      { 
+       container->push_back(__value);
+       return *this;
+      }
+
+      back_insert_iterator<_Container>& 
+      operator*() { return *this; }
+
+      back_insert_iterator<_Container>& 
+      operator++() { return *this; }
+
+      back_insert_iterator<_Container>& 
+      operator++(int) { return *this; }
+    };
+
+  template <class _Container>
+    inline back_insert_iterator<_Container> 
+    back_inserter(_Container& __x) 
+    { return back_insert_iterator<_Container>(__x); }
+
+  template <class _Container>
+    class front_insert_iterator 
+      : public iterator<output_iterator_tag, void, void, void, void>
+    {
+    protected:
+      _Container* container;
+
+    public:
+      typedef _Container          container_type;
+
+      explicit front_insert_iterator(_Container& __x) : container(&__x) {}
+      front_insert_iterator<_Container>&
+      operator=(const typename _Container::value_type& __value) { 
+       container->push_front(__value);
+       return *this;
+      }
+      front_insert_iterator<_Container>& operator*() { return *this; }
+      front_insert_iterator<_Container>& operator++() { return *this; }
+      front_insert_iterator<_Container>& operator++(int) { return *this; }
+    };
+
+  template <class _Container>
+  inline front_insert_iterator<_Container> front_inserter(_Container& __x) {
+    return front_insert_iterator<_Container>(__x);
   }
-  front_insert_iterator<_Container>& operator*() { return *this; }
-  front_insert_iterator<_Container>& operator++() { return *this; }
-  front_insert_iterator<_Container>& operator++(int) { return *this; }
-};
-
-template <class _Container>
-inline front_insert_iterator<_Container> front_inserter(_Container& __x) {
-  return front_insert_iterator<_Container>(__x);
-}
 
-template <class _Container>
-class insert_iterator {
-protected:
-  _Container* container;
-  typename _Container::iterator iter;
-public:
-  typedef _Container          container_type;
-  typedef output_iterator_tag iterator_category;
-  typedef void                value_type;
-  typedef void                difference_type;
-  typedef void                pointer;
-  typedef void                reference;
-
-  insert_iterator(_Container& __x, typename _Container::iterator __i) 
-    : container(&__x), iter(__i) {}
-  insert_iterator<_Container>&
-  operator=(const typename _Container::value_type& __value) { 
-    iter = container->insert(iter, __value);
-    ++iter;
-    return *this;
+  template <class _Container>
+    class insert_iterator 
+      : public iterator<output_iterator_tag, void, void, void, void>
+    {
+    protected:
+      _Container* container;
+      typename _Container::iterator iter;
+
+    public:
+      typedef _Container          container_type;
+      
+      insert_iterator(_Container& __x, typename _Container::iterator __i) 
+       : container(&__x), iter(__i) {}
+   
+      insert_iterator<_Container>&
+      operator=(const typename _Container::value_type& __value) { 
+       iter = container->insert(iter, __value);
+       ++iter;
+       return *this;
+      }
+      insert_iterator<_Container>& operator*() { return *this; }
+      insert_iterator<_Container>& operator++() { return *this; }
+      insert_iterator<_Container>& operator++(int) { return *this; }
+    };
+  
+  template <class _Container, class _Iterator>
+  inline 
+  insert_iterator<_Container> inserter(_Container& __x, _Iterator __i)
+  {
+    typedef typename _Container::iterator __iter;
+    return insert_iterator<_Container>(__x, __iter(__i));
   }
-  insert_iterator<_Container>& operator*() { return *this; }
-  insert_iterator<_Container>& operator++() { return *this; }
-  insert_iterator<_Container>& operator++(int) { return *this; }
-};
-
-template <class _Container, class _Iterator>
-inline 
-insert_iterator<_Container> inserter(_Container& __x, _Iterator __i)
-{
-  typedef typename _Container::iterator __iter;
-  return insert_iterator<_Container>(__x, __iter(__i));
-}
-
-template <class _BidirectionalIterator, class _Tp, class _Reference = _Tp&, 
-          class _Distance = ptrdiff_t> 
-class reverse_bidirectional_iterator {
-  typedef reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, 
-                                         _Reference, _Distance>  _Self;
-protected:
-  _BidirectionalIterator current;
-public:
-  typedef bidirectional_iterator_tag iterator_category;
+  
+  template <class _BidirectionalIterator, class _Tp, class _Reference = _Tp&, 
+    class _Distance = ptrdiff_t> 
+  class reverse_bidirectional_iterator {
+    typedef reverse_bidirectional_iterator<_BidirectionalIterator, _Tp, 
+      _Reference, _Distance>  _Self;
+  protected:
+    _BidirectionalIterator current;
+  public:
+    typedef bidirectional_iterator_tag iterator_category;
   typedef _Tp                        value_type;
-  typedef _Distance                  difference_type;
+    typedef _Distance                  difference_type;
   typedef _Tp*                       pointer;
-  typedef _Reference                 reference;
-
+    typedef _Reference                 reference;
+    
   reverse_bidirectional_iterator() {}
-  explicit reverse_bidirectional_iterator(_BidirectionalIterator __x)
-    : current(__x) {}
-  _BidirectionalIterator base() const { return current; }
-  _Reference operator*() const {
-    _BidirectionalIterator __tmp = current;
+    explicit reverse_bidirectional_iterator(_BidirectionalIterator __x)
+      : current(__x) {}
+    _BidirectionalIterator base() const { return current; }
+    _Reference operator*() const {
+      _BidirectionalIterator __tmp = current;
     return *--__tmp;
   }
   pointer operator->() const { return &(operator*()); }
@@ -184,134 +339,6 @@ inline bool operator!=(
 }
 
 
-// This is the new version of reverse_iterator, as defined in the
-//  draft C++ standard.  It relies on the iterator_traits template,
-//  which in turn relies on partial specialization.  The class
-//  reverse_bidirectional_iterator is no longer part of the draft
-//  standard, but it is retained for backward compatibility.
-
-template <class _Iterator>
-class reverse_iterator 
-{
-protected:
-  _Iterator current;
-public:
-  typedef typename iterator_traits<_Iterator>::iterator_category
-          iterator_category;
-  typedef typename iterator_traits<_Iterator>::value_type
-          value_type;
-  typedef typename iterator_traits<_Iterator>::difference_type
-          difference_type;
-  typedef typename iterator_traits<_Iterator>::pointer
-          pointer;
-  typedef typename iterator_traits<_Iterator>::reference
-          reference;
-
-  typedef _Iterator iterator_type;
-  typedef reverse_iterator<_Iterator> _Self;
-
-public:
-  reverse_iterator() {}
-  explicit reverse_iterator(iterator_type __x) : current(__x) {}
-
-  reverse_iterator(const _Self& __x) : current(__x.current) {}
-  template <class _Iter>
-  reverse_iterator(const reverse_iterator<_Iter>& __x)
-    : current(__x.base()) {}
-    
-  iterator_type base() const { return current; }
-  reference operator*() const {
-    _Iterator __tmp = current;
-    return *--__tmp;
-  }
-  pointer operator->() const { return &(operator*()); }
-
-  _Self& operator++() {
-    --current;
-    return *this;
-  }
-  _Self operator++(int) {
-    _Self __tmp = *this;
-    --current;
-    return __tmp;
-  }
-  _Self& operator--() {
-    ++current;
-    return *this;
-  }
-  _Self operator--(int) {
-    _Self __tmp = *this;
-    ++current;
-    return __tmp;
-  }
-
-  _Self operator+(difference_type __n) const {
-    return _Self(current - __n);
-  }
-  _Self& operator+=(difference_type __n) {
-    current -= __n;
-    return *this;
-  }
-  _Self operator-(difference_type __n) const {
-    return _Self(current + __n);
-  }
-  _Self& operator-=(difference_type __n) {
-    current += __n;
-    return *this;
-  }
-  reference operator[](difference_type __n) const { return *(*this + __n); }  
-}; 
-template <class _Iterator>
-inline bool operator==(const reverse_iterator<_Iterator>& __x, 
-                       const reverse_iterator<_Iterator>& __y) {
-  return __x.base() == __y.base();
-}
-
-template <class _Iterator>
-inline bool operator<(const reverse_iterator<_Iterator>& __x, 
-                      const reverse_iterator<_Iterator>& __y) {
-  return __y.base() < __x.base();
-}
-
-template <class _Iterator>
-inline bool operator!=(const reverse_iterator<_Iterator>& __x, 
-                       const reverse_iterator<_Iterator>& __y) {
-  return !(__x == __y);
-}
-
-template <class _Iterator>
-inline bool operator>(const reverse_iterator<_Iterator>& __x, 
-                      const reverse_iterator<_Iterator>& __y) {
-  return __y < __x;
-}
-
-template <class _Iterator>
-inline bool operator<=(const reverse_iterator<_Iterator>& __x, 
-                       const reverse_iterator<_Iterator>& __y) {
-  return !(__y < __x);
-}
-
-template <class _Iterator>
-inline bool operator>=(const reverse_iterator<_Iterator>& __x, 
-                      const reverse_iterator<_Iterator>& __y) {
-  return !(__x < __y);
-}
-
-template <class _Iterator>
-inline typename reverse_iterator<_Iterator>::difference_type
-operator-(const reverse_iterator<_Iterator>& __x, 
-          const reverse_iterator<_Iterator>& __y) {
-  return __y.base() - __x.base();
-}
-
-template <class _Iterator>
-inline reverse_iterator<_Iterator> 
-operator+(typename reverse_iterator<_Iterator>::difference_type __n,
-          const reverse_iterator<_Iterator>& __x) {
-  return reverse_iterator<_Iterator>(__x.base() - __n);
-}
-
 
 template <class _Tp, 
           class _CharT = char, class _Traits = char_traits<_CharT>,
@@ -428,12 +455,6 @@ protected:
 
 public:
   typedef __normal_iterator<_Iterator, _Container> normal_iterator_type;
-  typedef iterator_traits<_Iterator>                   __traits_type;
-  typedef typename __traits_type::iterator_category    iterator_category;
-  typedef typename __traits_type::value_type           value_type;
-  typedef typename __traits_type::difference_type      difference_type;
-  typedef typename __traits_type::pointer              pointer;
-  typedef typename __traits_type::reference            reference;
 
   __normal_iterator() : _M_current(_Iterator()) { }
 
index de1fe691e14ec1b6a8940d06379e1b50e30b6a6e..7d59a8a6099524c138da6b0ffaad74b4f5f8a854 100644 (file)
@@ -28,16 +28,17 @@ void test01()
 
   // Check for required base class.
   long l;
-  raw_storage_iterator<long*, long> rs_it(&l);
-  iterator<output_iterator_tag, void, void, void, void>* base = &rs_it;
+  typedef raw_storage_iterator<long*, long> test_iterator;
+  typedef iterator<output_iterator_tag, void, void, void, void> base_iterator;
+  test_iterator rs_it(&l);
+  base_iterator* base = &rs_it;
 
   // Check for required typedefs
-  typedef raw_storage_iterator<long*, long>::value_type value_type;
-  typedef raw_storage_iterator<long*, long>::difference_type difference_type;
-  typedef raw_storage_iterator<long*, long>::pointer pointer;
-  typedef raw_storage_iterator<long*, long>::reference reference;
-  typedef raw_storage_iterator<long*, long>::iterator_category iteratory_category;
-
+  typedef test_iterator::value_type value_type;
+  typedef test_iterator::difference_type difference_type;
+  typedef test_iterator::pointer pointer;
+  typedef test_iterator::reference reference;
+  typedef test_iterator::iterator_category iteratory_category;
 }
 
 int main() 
diff --git a/libstdc++-v3/testsuite/24_iterators/back_insert_iterator.cc b/libstdc++-v3/testsuite/24_iterators/back_insert_iterator.cc
new file mode 100644 (file)
index 0000000..87d2d79
--- /dev/null
@@ -0,0 +1,50 @@
+// 2001-06-21  Benjamin Kosnik  <bkoz@redhat.com>
+
+// 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.
+
+// 24.4.2.1 Template class back_insert_iterator
+
+#include <iterator>
+#include <list>
+
+void test01()
+{
+  using namespace std;
+
+  // Check for required base class.
+  list<int> l;
+  typedef back_insert_iterator<list<int> > test_iterator;
+  typedef iterator<output_iterator_tag, void, void, void, void> base_iterator;
+  test_iterator  r_it(l);
+  base_iterator* base = &r_it;
+
+  // Check for required typedefs
+  typedef test_iterator::value_type value_type;
+  typedef test_iterator::difference_type difference_type;
+  typedef test_iterator::pointer pointer;
+  typedef test_iterator::reference reference;
+  typedef test_iterator::iterator_category iteratory_category;
+  typedef test_iterator::container_type container_type;
+}
+
+int main() 
+{ 
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/24_iterators/front_insert_iterator.cc b/libstdc++-v3/testsuite/24_iterators/front_insert_iterator.cc
new file mode 100644 (file)
index 0000000..5e0d04f
--- /dev/null
@@ -0,0 +1,50 @@
+// 2001-06-21  Benjamin Kosnik  <bkoz@redhat.com>
+
+// 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.
+
+// 24.4.2.3 Template class front_insert_iterator
+
+#include <iterator>
+#include <list>
+
+void test01()
+{
+  using namespace std;
+
+  // Check for required base class.
+  list<int> l;
+  typedef front_insert_iterator<list<int> > test_iterator;
+  typedef iterator<output_iterator_tag, void, void, void, void> base_iterator;
+  test_iterator  r_it(l);
+  base_iterator* base = &r_it;
+
+  // Check for required typedefs
+  typedef test_iterator::value_type value_type;
+  typedef test_iterator::difference_type difference_type;
+  typedef test_iterator::pointer pointer;
+  typedef test_iterator::reference reference;
+  typedef test_iterator::iterator_category iteratory_category;
+  typedef test_iterator::container_type container_type;
+}
+
+int main() 
+{ 
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/24_iterators/insert_iterator.cc b/libstdc++-v3/testsuite/24_iterators/insert_iterator.cc
new file mode 100644 (file)
index 0000000..aee2470
--- /dev/null
@@ -0,0 +1,52 @@
+// 2001-06-21  Benjamin Kosnik  <bkoz@redhat.com>
+
+// 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.
+
+// 24.4.2.5 Template class insert_iterator
+
+#include <iterator>
+#include <list>
+
+void test01()
+{
+  using namespace std;
+
+  // Check for required base class.
+  list<int> l;
+  list<int>::iterator li;
+
+  typedef insert_iterator<list<int> > test_iterator;
+  typedef iterator<output_iterator_tag, void, void, void, void> base_iterator;
+  test_iterator  r_it(l, li);
+  base_iterator* base = &r_it;
+
+  // Check for required typedefs
+  typedef test_iterator::value_type value_type;
+  typedef test_iterator::difference_type difference_type;
+  typedef test_iterator::pointer pointer;
+  typedef test_iterator::reference reference;
+  typedef test_iterator::iterator_category iteratory_category;
+  typedef test_iterator::container_type container_type;
+}
+
+int main() 
+{ 
+  test01();
+  return 0;
+}
diff --git a/libstdc++-v3/testsuite/24_iterators/reverse_iterator.cc b/libstdc++-v3/testsuite/24_iterators/reverse_iterator.cc
new file mode 100644 (file)
index 0000000..606d393
--- /dev/null
@@ -0,0 +1,53 @@
+// 2001-06-21  Benjamin Kosnik  <bkoz@redhat.com>
+
+// 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.
+
+// 24.4.1.2 Reverse iterators
+
+#include <iterator>
+
+void test01()
+{
+  using namespace std;
+
+  // Check for required base class.
+  long l;
+  typedef reverse_iterator<long*> test_iterator;
+  typedef iterator<iterator_traits<long*>::iterator_category,
+                  iterator_traits<long*>::value_type,
+                  iterator_traits<long*>::difference_type,
+                  iterator_traits<long*>::pointer,
+                   iterator_traits<long*>::reference>
+    base_iterator;
+  test_iterator  r_it(&l);
+  base_iterator* base = &r_it;
+
+  // Check for required typedefs
+  typedef test_iterator::value_type value_type;
+  typedef test_iterator::difference_type difference_type;
+  typedef test_iterator::pointer pointer;
+  typedef test_iterator::reference reference;
+  typedef test_iterator::iterator_category iteratory_category;
+}
+
+int main() 
+{ 
+  test01();
+  return 0;
+}