This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[v3] 24, two of three




2001-06-25  Benjamin Kosnik  <bkoz@redhat.com>

	* include/bits/std_iterator.h: Include sbuf_iter.h via std_ios.h.

	* include/bits/stl_iterator.h (istream_iterator): Inherit from
	iterator.
	(ostream_iterator): Same.
	* testsuite/24_iterators/istream_iterator.cc: New file.
	* testsuite/24_iterators/ostream_iterator.cc: New file.
	
	* include/bits/sbuf_iter.h: Remove self typedef.
	* testsuite/24_iterators/ostreambuf_iterator.cc: Add test.
	* testsuite/24_iterators/istreambuf_iterator.cc: Add test.
	
	* include/bits/stl_iterator.h (reverse_iterator): Remove
	extraneous typedefs. Add typename.
	(__normal_iterator): Remove typedefs referring to self. Add typename.
	(reverse_bidiretional_iterator): Remove, not longer required.

Index: include/bits/sbuf_iter.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/sbuf_iter.h,v
retrieving revision 1.8
diff -c -p -r1.8 sbuf_iter.h
*** sbuf_iter.h	2001/05/31 12:14:54	1.8
--- sbuf_iter.h	2001/06/26 06:35:39
*************** namespace std
*** 103,110 ****
        typedef typename _Traits::int_type     		int_type;
        typedef basic_streambuf<_CharT, _Traits> 		streambuf_type;
        typedef basic_istream<_CharT, _Traits>         	istream_type;
-       // Non-standard Types:
-       typedef istreambuf_iterator<_CharT, _Traits>	__istreambufiter_type;
  
      private:
        // 24.5.3 istreambuf_iterator 
--- 103,108 ----
*************** namespace std
*** 144,150 ****
  	return __ret;
        }
  	
!       __istreambufiter_type& 
        operator++()
        { 
  	if (_M_sbuf)
--- 142,148 ----
  	return __ret;
        }
  	
!       istreambuf_iterator& 
        operator++()
        { 
  	if (_M_sbuf)
*************** namespace std
*** 153,162 ****
  	return *this; 
        }
  
!       __istreambufiter_type
        operator++(int)
        {
! 	__istreambufiter_type __old = *this;
  	if (_M_sbuf)
  	  __old._M_c = _M_sbuf->sbumpc();
  	_M_c = -2;
--- 151,160 ----
  	return *this; 
        }
  
!       istreambuf_iterator
        operator++(int)
        {
! 	istreambuf_iterator __old = *this;
  	if (_M_sbuf)
  	  __old._M_c = _M_sbuf->sbumpc();
  	_M_c = -2;
*************** namespace std
*** 164,170 ****
        }
  
        bool 
!       equal(const __istreambufiter_type& __b)
        { 
  	int_type __eof = traits_type::eof();
  	bool __thiseof = !_M_sbuf || _M_sbuf->sgetc() == __eof;
--- 162,168 ----
        }
  
        bool 
!       equal(const istreambuf_iterator& __b)
        { 
  	int_type __eof = traits_type::eof();
  	bool __thiseof = !_M_sbuf || _M_sbuf->sgetc() == __eof;
*************** namespace std
*** 177,183 ****
        // 110 istreambuf_iterator::equal not const
        // NB: there is also number 111 pending on this function.
        bool 
!       equal(const __istreambufiter_type& __b) const
        {
  	int_type __eof = traits_type::eof();
  	bool __thiseof = !_M_sbuf || _M_sbuf->sgetc() == __eof;
--- 175,181 ----
        // 110 istreambuf_iterator::equal not const
        // NB: there is also number 111 pending on this function.
        bool 
!       equal(const istreambuf_iterator& __b) const
        {
  	int_type __eof = traits_type::eof();
  	bool __thiseof = !_M_sbuf || _M_sbuf->sgetc() == __eof;
Index: include/bits/std_iterator.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/std_iterator.h,v
retrieving revision 1.8
diff -c -p -r1.8 std_iterator.h
*** std_iterator.h	2001/06/22 19:53:30	1.8
--- std_iterator.h	2001/06/26 06:35:40
***************
*** 30,36 ****
  #pragma GCC system_header
  #include <bits/c++config.h>
  #include <bits/std_cstddef.h>
! #include <bits/std_iosfwd.h>
  #include <bits/stl_iterator_base_types.h>
  #include <bits/stl_iterator_base_funcs.h>
  #include <bits/stl_iterator.h>
--- 30,36 ----
  #pragma GCC system_header
  #include <bits/c++config.h>
  #include <bits/std_cstddef.h>
! #include <bits/std_ios.h>
  #include <bits/stl_iterator_base_types.h>
  #include <bits/stl_iterator_base_funcs.h>
  #include <bits/stl_iterator.h>
Index: include/bits/stl_iterator.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_iterator.h,v
retrieving revision 1.5
diff -c -p -r1.5 stl_iterator.h
*** stl_iterator.h	2001/06/23 00:08:46	1.5
--- stl_iterator.h	2001/06/26 06:35:41
***************
*** 34,134 ****
  namespace std
  {
    // 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;
        }
  
--- 34,131 ----
  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>
      {
      protected:
!       _Iterator _M_current;
  
      public:
!       typedef _Iterator 				       iterator_type;
!       typedef typename iterator_traits<_Iterator>::difference_type 	
!       							       difference_type;
!       typedef typename iterator_traits<_Iterator>::reference   reference;
!       typedef typename iterator_traits<_Iterator>::pointer     pointer;
  
      public:
        reverse_iterator() {}
  
        explicit 
!       reverse_iterator(iterator_type __x) : _M_current(__x) {}
  
!       reverse_iterator(const reverse_iterator& __x) 
! 	: _M_current(__x._M_current) { }
  
!       template<typename _Iter>
          reverse_iterator(const reverse_iterator<_Iter>& __x)
! 	: _M_current(__x.base()) {}
      
        iterator_type 
!       base() const { return _M_current; }
  
        reference 
        operator*() const 
        {
! 	_Iterator __tmp = _M_current;
  	return *--__tmp;
        }
  
        pointer 
        operator->() const { return &(operator*()); }
  
!       reverse_iterator& 
        operator++() 
        {
! 	--_M_current;
  	return *this;
        }
  
!       reverse_iterator 
        operator++(int) 
        {
! 	reverse_iterator __tmp = *this;
! 	--_M_current;
  	return __tmp;
        }
  
!       reverse_iterator& 
        operator--() 
        {
! 	++_M_current;
  	return *this;
        }
  
!       reverse_iterator operator--(int) 
        {
! 	reverse_iterator __tmp = *this;
! 	++_M_current;
  	return __tmp;
        }
        
!       reverse_iterator 
        operator+(difference_type __n) const 
!       { return reverse_iterator(_M_current - __n); }
  
!       reverse_iterator& 
        operator+=(difference_type __n) 
        {
! 	_M_current -= __n;
  	return *this;
        }
  
!       reverse_iterator 
        operator-(difference_type __n) const 
!       { return reverse_iterator(_M_current + __n); }
  
!       reverse_iterator& 
        operator-=(difference_type __n) 
        {
! 	_M_current += __n;
  	return *this;
        }
  
*************** namespace std
*** 136,191 ****
        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>
      {
--- 133,188 ----
        operator[](difference_type __n) const { return *(*this + __n); }  
      }; 
   
!   template<typename _Iterator>
      inline bool 
      operator==(const reverse_iterator<_Iterator>& __x, 
  	       const reverse_iterator<_Iterator>& __y) 
      { return __x.base() == __y.base(); }
  
!   template<typename _Iterator>
      inline bool 
      operator<(const reverse_iterator<_Iterator>& __x, 
  	      const reverse_iterator<_Iterator>& __y) 
      { return __y.base() < __x.base(); }
  
!   template<typename _Iterator>
      inline bool 
      operator!=(const reverse_iterator<_Iterator>& __x, 
  	       const reverse_iterator<_Iterator>& __y) 
      { return !(__x == __y); }
  
!   template<typename _Iterator>
      inline bool 
      operator>(const reverse_iterator<_Iterator>& __x, 
  	      const reverse_iterator<_Iterator>& __y) 
      { return __y < __x; }
  
!   template<typename _Iterator>
      inline bool 
      operator<=(const reverse_iterator<_Iterator>& __x, 
  		const reverse_iterator<_Iterator>& __y) 
      { return !(__y < __x); }
  
!   template<typename _Iterator>
      inline bool 
      operator>=(const reverse_iterator<_Iterator>& __x, 
  	       const reverse_iterator<_Iterator>& __y) 
      { return !(__x < __y); }
  
!   template<typename _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<typename _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<typename _Container>
    class back_insert_iterator 
      : public iterator<output_iterator_tag, void, void, void, void>
      {
*************** namespace std
*** 215,226 ****
        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>
      {
--- 212,223 ----
        operator++(int) { return *this; }
      };
  
!   template<typename _Container>
      inline back_insert_iterator<_Container> 
      back_inserter(_Container& __x) 
      { return back_insert_iterator<_Container>(__x); }
  
!   template<typename _Container>
      class front_insert_iterator 
        : public iterator<output_iterator_tag, void, void, void, void>
      {
*************** namespace std
*** 241,252 ****
        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 
        : public iterator<output_iterator_tag, void, void, void, void>
      {
--- 238,248 ----
        front_insert_iterator<_Container>& operator++(int) { return *this; }
      };
  
!   template<typename _Container>
!   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>
      {
*************** namespace std
*** 270,568 ****
        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;
!   typedef _Tp                        value_type;
!     typedef _Distance                  difference_type;
!   typedef _Tp*                       pointer;
!     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;
!     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;
!   }
! };
! 
! template <class _BiIter, class _Tp, class _Ref, class _Distance>
! inline bool operator==(
!     const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __x, 
!     const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __y)
! {
!   return __x.base() == __y.base();
! }
! 
! template <class _BiIter, class _Tp, class _Ref, class _Distance>
! inline bool operator!=(
!     const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __x, 
!     const reverse_bidirectional_iterator<_BiIter, _Tp, _Ref, _Distance>& __y)
! {
!   return !(__x == __y);
! }
! 
! 
! 
! template <class _Tp, 
!           class _CharT = char, class _Traits = char_traits<_CharT>,
!           class _Dist = ptrdiff_t> 
! class istream_iterator {
! public:
!   typedef _CharT                         char_type;
!   typedef _Traits                        traits_type;
!   typedef basic_istream<_CharT, _Traits> istream_type;
! 
!   typedef input_iterator_tag             iterator_category;
!   typedef _Tp                            value_type;
!   typedef _Dist                          difference_type;
!   typedef const _Tp*                     pointer;
!   typedef const _Tp&                     reference;
! 
!   istream_iterator() : _M_stream(0), _M_ok(false) {}
!   istream_iterator(istream_type& __s) : _M_stream(&__s) { _M_read(); }
! 
!   reference operator*() const { return _M_value; }
!   pointer operator->() const { return &(operator*()); }
! 
!   istream_iterator& operator++() { 
!     _M_read(); 
!     return *this;
!   }
!   istream_iterator operator++(int)  {
!     istream_iterator __tmp = *this;
!     _M_read();
!     return __tmp;
!   }
! 
!   bool _M_equal(const istream_iterator& __x) const
!     { return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream); }
! 
! private:
!   istream_type* _M_stream;
!   _Tp _M_value;
!   bool _M_ok;
! 
!   void _M_read() {
!     _M_ok = (_M_stream && *_M_stream) ? true : false;
!     if (_M_ok) {
!       *_M_stream >> _M_value;
!       _M_ok = *_M_stream ? true : false;
      }
!   }
! };
  
! template <class _Tp, class _CharT, class _Traits, class _Dist>
! inline bool 
! operator==(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x,
!            const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y) {
!   return __x._M_equal(__y);
! }
! 
! template <class _Tp, class _CharT, class _Traits, class _Dist>
! inline bool 
! operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x,
!            const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y) {
!   return !__x._M_equal(__y);
! }
! 
! 
! template <class _Tp,
!           class _CharT = char, class _Traits = char_traits<_CharT> >
! class ostream_iterator {
! public:
!   typedef _CharT                         char_type;
!   typedef _Traits                        traits_type;
!   typedef basic_ostream<_CharT, _Traits> ostream_type;
! 
!   typedef output_iterator_tag            iterator_category;
!   typedef void                           value_type;
!   typedef void                           difference_type;
!   typedef void                           pointer;
!   typedef void                           reference;
! 
!   ostream_iterator(ostream_type& __s) : _M_stream(&__s), _M_string(0) {}
!   ostream_iterator(ostream_type& __s, const _CharT* __c) 
!     : _M_stream(&__s), _M_string(__c)  {}
!   ostream_iterator<_Tp>& operator=(const _Tp& __value) { 
!     *_M_stream << __value;
!     if (_M_string) *_M_stream << _M_string;
!     return *this;
!   }
!   ostream_iterator<_Tp>& operator*() { return *this; }
!   ostream_iterator<_Tp>& operator++() { return *this; } 
!   ostream_iterator<_Tp>& operator++(int) { return *this; } 
! private:
!   ostream_type* _M_stream;
!   const _CharT* _M_string;
! };
! 
! 
! // This iterator adapter is 'normal' in the sense that it does not
! // change the semantics of any of the operators of its itererator
! // 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
! // using this template can instantiate different types, even if the
! // _Iterator parameter is the same.
! template<typename _Iterator, typename _Container>
! class __normal_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 _M_current;
! 
! public:
!   typedef __normal_iterator<_Iterator, _Container> normal_iterator_type;
! 
!   __normal_iterator() : _M_current(_Iterator()) { }
! 
!   explicit __normal_iterator(const _Iterator& __i) : _M_current(__i) { }
! 
!   // Allow iterator to const_iterator conversion
!   template<typename _Iter>
!   inline __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)
!     : _M_current(__i.base()) { }
  
!   // Forward iterator requirements
!   reference
!   operator*() const { return *_M_current; }
  
!   pointer
!   operator->() const { return _M_current; }
  
!   normal_iterator_type&
!   operator++() { ++_M_current; return *this; }
  
!   normal_iterator_type
!   operator++(int) { return __normal_iterator(_M_current++); }
  
-   // Bidirectional iterator requirements
-   normal_iterator_type&
-   operator--() { --_M_current; return *this; }
  
!   normal_iterator_type
!   operator--(int) { return __normal_iterator(_M_current--); }
  
!   // Random access iterator requirements
!   reference
!   operator[](const difference_type& __n) const
!   { return _M_current[__n]; }
! 
!   normal_iterator_type&
!   operator+=(const difference_type& __n)
!   { _M_current += __n; return *this; }
! 
!   normal_iterator_type
!   operator+(const difference_type& __n) const
!   { return __normal_iterator(_M_current + __n); }
! 
!   normal_iterator_type&
!   operator-=(const difference_type& __n)
!   { _M_current -= __n; return *this; }
! 
!   normal_iterator_type
!   operator-(const difference_type& __n) const
!   { return __normal_iterator(_M_current - __n); }
! 
!   difference_type
!   operator-(const normal_iterator_type& __i) const
!   { return _M_current - __i._M_current; }
! 
!   const _Iterator& 
!   base() const { return _M_current; }
! };
! 
! // forward iterator requirements
! 
! template<typename _IteratorL, typename _IteratorR, typename _Container>
! inline bool
! operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
! 	   const __normal_iterator<_IteratorR, _Container>& __rhs)
! { return __lhs.base() == __rhs.base(); }
! 
! template<typename _IteratorL, typename _IteratorR, typename _Container>
! inline bool
! operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
! 	   const __normal_iterator<_IteratorR, _Container>& __rhs)
! { return !(__lhs == __rhs); }
! 
! // random access iterator requirements
! 
! template<typename _IteratorL, typename _IteratorR, typename _Container>
! inline bool 
! operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
! 	  const __normal_iterator<_IteratorR, _Container>& __rhs)
! { return __lhs.base() < __rhs.base(); }
! 
! template<typename _IteratorL, typename _IteratorR, typename _Container>
! inline bool
! operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
! 	  const __normal_iterator<_IteratorR, _Container>& __rhs)
! { return __rhs < __lhs; }
! 
! template<typename _IteratorL, typename _IteratorR, typename _Container>
! inline bool
! operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
! 	   const __normal_iterator<_IteratorR, _Container>& __rhs)
! { return !(__rhs < __lhs); }
! 
! template<typename _IteratorL, typename _IteratorR, typename _Container>
! inline bool
! operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
! 	   const __normal_iterator<_IteratorR, _Container>& __rhs)
! { return !(__lhs < __rhs); }
! 
! template<typename _Iterator, typename _Container>
! inline __normal_iterator<_Iterator, _Container>
! operator+(__normal_iterator<_Iterator, _Container>::difference_type __n,
!           const __normal_iterator<_Iterator, _Container>& __i)
! { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
  
  } // namespace std
  
! #endif /* __SGI_STL_INTERNAL_ITERATOR_H */
  
  // Local Variables:
  // mode:C++
--- 266,514 ----
        insert_iterator<_Container>& operator++() { return *this; }
        insert_iterator<_Container>& operator++(int) { return *this; }
      };
    
!   template<typename _Container, typename _Iterator>
!     inline 
!     insert_iterator<_Container> inserter(_Container& __x, _Iterator __i)
!     {
!       typedef typename _Container::iterator __iter;
!       return insert_iterator<_Container>(__x, __iter(__i));
      }
!   
  
!   template<typename _Tp, typename _CharT = char, 
!            typename _Traits = char_traits<_CharT>, typename _Dist = ptrdiff_t> 
!     class istream_iterator 
!       : public iterator<input_iterator_tag, _Tp, _Dist, const _Tp*, const _Tp&>
!     {
!     public:
!       typedef _CharT                         char_type;
!       typedef _Traits                        traits_type;
!       typedef basic_istream<_CharT, _Traits> istream_type;
! 
!     private:
!       istream_type* 	_M_stream;
!       _Tp 		_M_value;
!       bool 		_M_ok;
! 
!     public:      
!       istream_iterator() : _M_stream(0), _M_ok(false) {}
!       istream_iterator(istream_type& __s) : _M_stream(&__s) { _M_read(); }
  
!       reference 
!       operator*() const { return _M_value; }
! 
!       pointer 
!       operator->() const { return &(operator*()); }
! 
!       istream_iterator& 
!       operator++() 
!       { _M_read(); return *this; }
! 
!       istream_iterator 
!       operator++(int)  
!       {
! 	istream_iterator __tmp = *this;
! 	_M_read();
! 	return __tmp;
!       }
  
!       bool 
!       _M_equal(const istream_iterator& __x) const
!       { return (_M_ok == __x._M_ok) && (!_M_ok || _M_stream == __x._M_stream);}
  
!     private:      
!       void _M_read() 
!       {
! 	_M_ok = (_M_stream && *_M_stream) ? true : false;
! 	if (_M_ok) 
! 	  {
! 	    *_M_stream >> _M_value;
! 	    _M_ok = *_M_stream ? true : false;
! 	  }
!       }
!     };
!   
!   template<typename _Tp, typename _CharT, typename _Traits, typename _Dist>
!     inline bool 
!     operator==(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x,
! 	       const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y) 
!     { return __x._M_equal(__y); }
  
!   template<typename _Tp, typename _CharT, typename _Traits, typename _Dist>
!     inline bool 
!     operator!=(const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __x,
! 	       const istream_iterator<_Tp, _CharT, _Traits, _Dist>& __y) 
!     { return !__x._M_equal(__y); }
  
  
!   template<typename _Tp, typename _CharT = char, 
!            typename _Traits = char_traits<_CharT> >
!     class ostream_iterator 
!       : public iterator<output_iterator_tag, void, void, void, void>
!     {
!     public:
!       typedef _CharT                         char_type;
!       typedef _Traits                        traits_type;
!       typedef basic_ostream<_CharT, _Traits> ostream_type;
! 
!     private:
!       ostream_type* 	_M_stream;
!       const _CharT* 	_M_string;
  
!     public:
!       ostream_iterator(ostream_type& __s) : _M_stream(&__s), _M_string(0) {}
!       ostream_iterator(ostream_type& __s, const _CharT* __c) 
! 	: _M_stream(&__s), _M_string(__c)  { }
  
+       ostream_iterator& 
+       operator=(const _Tp& __value) 
+       { 
+ 	*_M_stream << __value;
+ 	if (_M_string) *_M_stream << _M_string;
+ 	return *this;
+       }
+       
+       ostream_iterator& 
+       operator*() { return *this; }
+       
+       ostream_iterator& 
+       operator++() { return *this; } 
+       
+       ostream_iterator& 
+       operator++(int) { return *this; } 
+     };
+   
+   
+   // This iterator adapter is 'normal' in the sense that it does not
+   // change the semantics of any of the operators of its itererator
+   // 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
+   // using this template can instantiate different types, even if the
+   // _Iterator parameter is the same.
+   template<typename _Iterator, typename _Container>
+     class __normal_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>
+     {
+     protected:
+       _Iterator _M_current;
+       
+     public:
+       typedef typename iterator_traits<_Iterator>::difference_type 	
+       							       difference_type;
+       typedef typename iterator_traits<_Iterator>::reference   reference;
+       typedef typename iterator_traits<_Iterator>::pointer     pointer;
+ 
+       __normal_iterator() : _M_current(_Iterator()) { }
+ 
+       explicit 
+       __normal_iterator(const _Iterator& __i) : _M_current(__i) { }
+ 
+       // Allow iterator to const_iterator conversion
+       template<typename _Iter>
+       inline __normal_iterator(const __normal_iterator<_Iter, _Container>& __i)
+ 	: _M_current(__i.base()) { }
+ 
+       // Forward iterator requirements
+       reference
+       operator*() const { return *_M_current; }
+       
+       pointer
+       operator->() const { return _M_current; }
+       
+       __normal_iterator&
+       operator++() { ++_M_current; return *this; }
+       
+       __normal_iterator
+       operator++(int) { return __normal_iterator(_M_current++); }
+       
+       // Bidirectional iterator requirements
+       __normal_iterator&
+       operator--() { --_M_current; return *this; }
+       
+       __normal_iterator
+       operator--(int) { return __normal_iterator(_M_current--); }
+       
+       // Random access iterator requirements
+       reference
+       operator[](const difference_type& __n) const
+       { return _M_current[__n]; }
+       
+       __normal_iterator&
+       operator+=(const difference_type& __n)
+       { _M_current += __n; return *this; }
+ 
+       __normal_iterator
+       operator+(const difference_type& __n) const
+       { return __normal_iterator(_M_current + __n); }
+       
+       __normal_iterator&
+       operator-=(const difference_type& __n)
+       { _M_current -= __n; return *this; }
+       
+       __normal_iterator
+       operator-(const difference_type& __n) const
+       { return __normal_iterator(_M_current - __n); }
+       
+       difference_type
+       operator-(const __normal_iterator& __i) const
+       { return _M_current - __i._M_current; }
+       
+       const _Iterator& 
+       base() const { return _M_current; }
+     };
+ 
+   // Forward iterator requirements
+   template<typename _IteratorL, typename _IteratorR, typename _Container>
+   inline bool
+   operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
+ 	     const __normal_iterator<_IteratorR, _Container>& __rhs)
+   { return __lhs.base() == __rhs.base(); }
+ 
+   template<typename _IteratorL, typename _IteratorR, typename _Container>
+   inline bool
+   operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
+ 	     const __normal_iterator<_IteratorR, _Container>& __rhs)
+   { return !(__lhs == __rhs); }
+ 
+   // Random access iterator requirements
+   template<typename _IteratorL, typename _IteratorR, typename _Container>
+   inline bool 
+   operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
+ 	    const __normal_iterator<_IteratorR, _Container>& __rhs)
+   { return __lhs.base() < __rhs.base(); }
+ 
+   template<typename _IteratorL, typename _IteratorR, typename _Container>
+   inline bool
+   operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
+ 	    const __normal_iterator<_IteratorR, _Container>& __rhs)
+   { return __rhs < __lhs; }
+ 
+   template<typename _IteratorL, typename _IteratorR, typename _Container>
+   inline bool
+   operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
+ 	     const __normal_iterator<_IteratorR, _Container>& __rhs)
+   { return !(__rhs < __lhs); }
+ 
+   template<typename _IteratorL, typename _IteratorR, typename _Container>
+   inline bool
+   operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
+ 	     const __normal_iterator<_IteratorR, _Container>& __rhs)
+   { return !(__lhs < __rhs); }
+ 
+   template<typename _Iterator, typename _Container>
+   inline __normal_iterator<_Iterator, _Container>
+   operator+(__normal_iterator<_Iterator, _Container>::difference_type __n,
+ 	    const __normal_iterator<_Iterator, _Container>& __i)
+   { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
  } // namespace std
  
! #endif 
  
  // Local Variables:
  // mode:C++
Index: testsuite/24_iterators/istream_iterator.cc
===================================================================
RCS file: istream_iterator.cc
diff -N istream_iterator.cc
*** /dev/null	Tue May  5 13:32:27 1998
--- istream_iterator.cc	Mon Jun 25 23:35:42 2001
***************
*** 0 ****
--- 1,52 ----
+ // 2001-06-25  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.5.1 Template class istream_iterator
+ 
+ #include <iterator>
+ 
+ void test01()
+ {
+   using namespace std;
+ 
+   // Check for required base class.
+   typedef istream_iterator<long> test_iterator;
+   typedef iterator<input_iterator_tag, long, ptrdiff_t, const long*, 
+     		   const long&> base_iterator;
+   test_iterator  r_it;
+   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::char_type char_type;
+   typedef test_iterator::traits_type traits_type;
+   typedef test_iterator::istream_type istream_type;
+ }
+ 
+ int main() 
+ { 
+   test01();
+   return 0;
+ }
Index: testsuite/24_iterators/istreambuf_iterator.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/24_iterators/istreambuf_iterator.cc,v
retrieving revision 1.4
diff -c -p -r1.4 istreambuf_iterator.cc
*** istreambuf_iterator.cc	2001/05/12 16:51:42	1.4
--- istreambuf_iterator.cc	2001/06/26 06:35:43
***************
*** 24,32 ****
  #include <iterator>
  #include <debug_assert.h>
  
! bool test01(void)
  {
  
    typedef std::istreambuf_iterator<char> cistreambuf_iter;
    typedef cistreambuf_iter::streambuf_type cstreambuf_type;
    bool test = true;
--- 24,58 ----
  #include <iterator>
  #include <debug_assert.h>
  
! void test01()
  {
+   using namespace std;
  
+   // Check for required base class.
+   typedef istreambuf_iterator<char> test_iterator;
+   typedef char_traits<char>::off_type off_type;
+   typedef iterator<input_iterator_tag, char, off_type, char*, char&> base_iterator;
+ 
+   istringstream isstream("this tag");
+   test_iterator  r_it(isstream);
+   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::char_type char_type;
+   typedef test_iterator::traits_type traits_type;
+   typedef test_iterator::istream_type istream_type;
+   typedef test_iterator::streambuf_type streambuf_type;
+ }
+ 
+ bool test02(void)
+ {
+ 
    typedef std::istreambuf_iterator<char> cistreambuf_iter;
    typedef cistreambuf_iter::streambuf_type cstreambuf_type;
    bool test = true;
*************** bool test01(void)
*** 116,122 ****
  }
  
  // libstdc++/2627
! void test02()
  {
    bool test = true;
    const std::string s("free the vieques");
--- 142,148 ----
  }
  
  // libstdc++/2627
! void test03()
  {
    bool test = true;
    const std::string s("free the vieques");
*************** int main()
*** 155,160 ****
  {
    test01();
    test02();
! 
    return 0;
  }
--- 181,186 ----
  {
    test01();
    test02();
!   test03();
    return 0;
  }
Index: testsuite/24_iterators/ostream_iterator.cc
===================================================================
RCS file: ostream_iterator.cc
diff -N ostream_iterator.cc
*** /dev/null	Tue May  5 13:32:27 1998
--- ostream_iterator.cc	Mon Jun 25 23:35:43 2001
***************
*** 0 ****
--- 1,54 ----
+ // 2001-06-25  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.5.4 Template class ostream_iterator
+ 
+ #include <iterator>
+ #include <ostream>
+ #include <sstream>
+ 
+ void test01()
+ {
+   using namespace std;
+ 
+   // Check for required base class.
+   typedef ostream_iterator<long> test_iterator;
+   typedef iterator<output_iterator_tag, void, void, void, void> base_iterator;
+   ostringstream osstream("this tag");
+   test_iterator  r_it(osstream);
+   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::char_type char_type;
+   typedef test_iterator::traits_type traits_type;
+   typedef test_iterator::ostream_type ostream_type;
+ }
+ 
+ int main() 
+ { 
+   test01();
+   return 0;
+ }
Index: testsuite/24_iterators/ostreambuf_iterator.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/24_iterators/ostreambuf_iterator.cc,v
retrieving revision 1.3
diff -c -p -r1.3 ostreambuf_iterator.cc
*** ostreambuf_iterator.cc	2001/05/12 16:51:42	1.3
--- ostreambuf_iterator.cc	2001/06/26 06:35:43
***************
*** 24,31 ****
  #include <iterator>
  #include <debug_assert.h>
  
! bool test01(void)
  {
    typedef std::ostreambuf_iterator<char> costreambuf_iter;
    typedef costreambuf_iter::streambuf_type cstreambuf_type;
    bool test = true;
--- 24,55 ----
  #include <iterator>
  #include <debug_assert.h>
  
! void test01()
  {
+   using namespace std;
+ 
+   // Check for required base class.
+   typedef ostreambuf_iterator<char> test_iterator;
+   typedef iterator<output_iterator_tag, void, void, void, void> base_iterator;
+   ostringstream osstream("this tag");
+   test_iterator  r_it(osstream);
+   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::char_type char_type;
+   typedef test_iterator::traits_type traits_type;
+   typedef test_iterator::ostream_type ostream_type;
+   typedef test_iterator::streambuf_type streambuf_type;
+ }
+ 
+ bool test02(void)
+ {
    typedef std::ostreambuf_iterator<char> costreambuf_iter;
    typedef costreambuf_iter::streambuf_type cstreambuf_type;
    bool test = true;
*************** bool test01(void)
*** 93,98 ****
--- 117,123 ----
  int main()
  {
    test01();
+   test02();
  
    return 0;
  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]