Remove old iterator structs

Phil Edwards pedwards@disaster.jaj.com
Wed Dec 19 09:47:00 GMT 2001


Found these while doing some more doxygenating.  We don't use these old
names anywhere ourselves; so rather than uglifying them, we'll just move
them to the backwards-compat header altogether.

Like the comment says, these are a bunch of nonstandard template classes
that have now been replaced by the general iterator<>.  Removing them
makes this header much smaller, and requires only a few touchups in other
headers to keep the build and testsuite going.


I'll apply this to the trunk later today if there are no objections.


2001-12-19  Phil Edwards  <pme@gcc.gnu.org>

	* include/bits/stl_iterator_base_types.h (input_iterator,
	output_iterator, forward_iterator, bidirectional_iterator,
	random_access_iterator):  Move old names...
	* include/backward/iterator.h:  ...to here.
	* include/bits/stl_bvector.h:  Update.
	* include/ext/stl_rope.h:  Update.



Index: include/backward/iterator.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/backward/iterator.h,v
retrieving revision 1.10
diff -u -3 -p -r1.10 iterator.h
--- iterator.h	2001/09/04 22:05:33	1.10
+++ iterator.h	2001/12/19 17:43:38
@@ -46,11 +46,54 @@ using std::random_access_iterator_tag;
 #if 0
 using std::iterator;
 #endif
-using std::input_iterator;
-using std::output_iterator;
-using std::forward_iterator;
-using std::bidirectional_iterator;
-using std::random_access_iterator;
+
+// The base classes input_iterator, output_iterator, forward_iterator,
+// bidirectional_iterator, and random_access_iterator are not part of
+// the C++ standard.  (They have been replaced by struct iterator.)
+// They are included for backward compatibility with the HP STL.
+template<typename _Tp, typename _Distance>
+  struct input_iterator {
+    typedef input_iterator_tag iterator_category;
+    typedef _Tp                value_type;
+    typedef _Distance          difference_type;
+    typedef _Tp*               pointer;
+    typedef _Tp&               reference;
+  };
+
+struct output_iterator {
+  typedef output_iterator_tag iterator_category;
+  typedef void                value_type;
+  typedef void                difference_type;
+  typedef void                pointer;
+  typedef void                reference;
+};
+
+template<typename _Tp, typename _Distance>
+  struct forward_iterator {
+    typedef forward_iterator_tag iterator_category;
+    typedef _Tp                  value_type;
+    typedef _Distance            difference_type;
+    typedef _Tp*                 pointer;
+    typedef _Tp&                 reference;
+  };
+
+template<typename _Tp, typename _Distance>
+  struct bidirectional_iterator {
+    typedef bidirectional_iterator_tag iterator_category;
+    typedef _Tp                        value_type;
+    typedef _Distance                  difference_type;
+    typedef _Tp*                       pointer;
+    typedef _Tp&                       reference;
+  };
+
+template<typename _Tp, typename _Distance>
+  struct random_access_iterator {
+    typedef random_access_iterator_tag iterator_category;
+    typedef _Tp                        value_type;
+    typedef _Distance                  difference_type;
+    typedef _Tp*                       pointer;
+    typedef _Tp&                       reference;
+  };
 
 using std::iterator_traits;
 
Index: include/bits/stl_bvector.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_bvector.h,v
retrieving revision 1.8
diff -u -3 -p -r1.8 stl_bvector.h
--- stl_bvector.h	2001/12/06 20:29:31	1.8
+++ stl_bvector.h	2001/12/19 17:43:38
@@ -98,7 +98,7 @@ inline void swap(_Bit_reference __x, _Bi
   __y = __tmp;
 }
 
-struct _Bit_iterator_base : public random_access_iterator<bool, ptrdiff_t> 
+struct _Bit_iterator_base : public iterator<random_access_iterator_tag, bool>
 {
   unsigned int* _M_p;
   unsigned int _M_offset;
Index: include/bits/stl_iterator_base_types.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_iterator_base_types.h,v
retrieving revision 1.8
diff -u -3 -p -r1.8 stl_iterator_base_types.h
--- stl_iterator_base_types.h	2001/12/06 20:29:31	1.8
+++ stl_iterator_base_types.h	2001/12/19 17:43:38
@@ -77,54 +77,6 @@ namespace std
   struct bidirectional_iterator_tag : public forward_iterator_tag {};
   struct random_access_iterator_tag : public bidirectional_iterator_tag {};
 
-  // The base classes input_iterator, output_iterator, forward_iterator,
-  // bidirectional_iterator, and random_access_iterator are not part of
-  // the C++ standard.  (They have been replaced by struct iterator.)
-  // They are included for backward compatibility with the HP STL.
-
-  template<typename _Tp, typename _Distance>
-    struct input_iterator {
-      typedef input_iterator_tag iterator_category;
-      typedef _Tp                value_type;
-      typedef _Distance          difference_type;
-      typedef _Tp*               pointer;
-      typedef _Tp&               reference;
-    };
-
-  struct output_iterator {
-    typedef output_iterator_tag iterator_category;
-    typedef void                value_type;
-    typedef void                difference_type;
-    typedef void                pointer;
-    typedef void                reference;
-  };
-
-  template<typename _Tp, typename _Distance>
-    struct forward_iterator {
-      typedef forward_iterator_tag iterator_category;
-      typedef _Tp                  value_type;
-      typedef _Distance            difference_type;
-      typedef _Tp*                 pointer;
-      typedef _Tp&                 reference;
-    };
-
-  template<typename _Tp, typename _Distance>
-    struct bidirectional_iterator {
-      typedef bidirectional_iterator_tag iterator_category;
-      typedef _Tp                        value_type;
-      typedef _Distance                  difference_type;
-      typedef _Tp*                       pointer;
-      typedef _Tp&                       reference;
-    };
-
-  template<typename _Tp, typename _Distance>
-    struct random_access_iterator {
-      typedef random_access_iterator_tag iterator_category;
-      typedef _Tp                        value_type;
-      typedef _Distance                  difference_type;
-      typedef _Tp*                       pointer;
-      typedef _Tp&                       reference;
-    };
 
   template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
 	   typename _Pointer = _Tp*, typename _Reference = _Tp&>
Index: include/ext/stl_rope.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/ext/stl_rope.h,v
retrieving revision 1.11
diff -u -3 -p -r1.11 stl_rope.h
--- stl_rope.h	2001/12/13 00:41:02	1.11
+++ stl_rope.h	2001/12/19 17:43:39
@@ -122,7 +122,8 @@ class char_producer {
 // little like containers.
 
 template<class _Sequence, size_t _Buf_sz = 100>
-class sequence_buffer : public output_iterator {
+class sequence_buffer : public iterator<output_iterator_tag,void,void,void,void>
+{
     public:
         typedef typename _Sequence::value_type value_type;
     protected:
@@ -837,7 +838,8 @@ class _Rope_char_ptr_proxy {
 
 template<class _CharT, class _Alloc>
 class _Rope_iterator_base
-  : public random_access_iterator<_CharT, ptrdiff_t> {
+  : public iterator<random_access_iterator_tag, _CharT>
+{
     friend class rope<_CharT,_Alloc>;
   public:
     typedef _Alloc _allocator_type; // used in _Rope_rotate, VC++ workaround



More information about the Libstdc++ mailing list