This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] iterators, first of two
- To: gcc-patches at gcc dot gnu dot org
- Subject: [v3] iterators, first of two
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Fri, 22 Jun 2001 17:07:39 -0700
More i-dotting, t-crossing.
-benjamin
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.
Index: include/bits/stl_iterator.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_iterator.h,v
retrieving revision 1.4
diff -c -p -r1.4 stl_iterator.h
*** stl_iterator.h 2001/06/22 19:53:31 1.4
--- stl_iterator.h 2001/06/23 00:06:28
***************
*** 33,149 ****
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;
! }
! 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;
! }
! 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;
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*()); }
--- 33,304 ----
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;
! }
!
! 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);
! }
!
! 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));
! }
!
! 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*()); }
*************** inline bool operator!=(
*** 184,317 ****
}
- // 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>,
--- 339,344 ----
*************** protected:
*** 428,439 ****
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()) { }
--- 455,460 ----
Index: testsuite/20_util/raw_storage_iterator.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/20_util/raw_storage_iterator.cc,v
retrieving revision 1.1
diff -c -p -r1.1 raw_storage_iterator.cc
*** raw_storage_iterator.cc 2001/06/19 01:51:33 1.1
--- raw_storage_iterator.cc 2001/06/23 00:06:30
*************** void test01()
*** 28,43 ****
// 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;
// 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;
!
}
int main()
--- 28,44 ----
// Check for required base class.
long l;
! 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 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()
Index: testsuite/24_iterators/back_insert_iterator.cc
===================================================================
RCS file: back_insert_iterator.cc
diff -N back_insert_iterator.cc
*** /dev/null Tue May 5 13:32:27 1998
--- back_insert_iterator.cc Fri Jun 22 17:06:30 2001
***************
*** 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;
+ }
Index: testsuite/24_iterators/front_insert_iterator.cc
===================================================================
RCS file: front_insert_iterator.cc
diff -N front_insert_iterator.cc
*** /dev/null Tue May 5 13:32:27 1998
--- front_insert_iterator.cc Fri Jun 22 17:06:30 2001
***************
*** 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;
+ }
Index: testsuite/24_iterators/insert_iterator.cc
===================================================================
RCS file: insert_iterator.cc
diff -N insert_iterator.cc
*** /dev/null Tue May 5 13:32:27 1998
--- insert_iterator.cc Fri Jun 22 17:06:30 2001
***************
*** 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;
+ }
Index: testsuite/24_iterators/reverse_iterator.cc
===================================================================
RCS file: reverse_iterator.cc
diff -N reverse_iterator.cc
*** /dev/null Tue May 5 13:32:27 1998
--- reverse_iterator.cc Fri Jun 22 17:06:31 2001
***************
*** 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;
+ }