mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-28 22:34:03 +08:00
stl_iterator.h (reverse_iterator): Inherit from iterator.
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
This commit is contained in:
parent
9401afe31a
commit
c766fc5f1c
@ -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
|
||||
|
@ -33,117 +33,272 @@
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
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;
|
||||
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);
|
||||
}
|
||||
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 insert_iterator
|
||||
: public iterator<output_iterator_tag, void, void, void, void>
|
||||
{
|
||||
protected:
|
||||
_Container* container;
|
||||
typename _Container::iterator iter;
|
||||
|
||||
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;
|
||||
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));
|
||||
}
|
||||
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;
|
||||
|
||||
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()) { }
|
||||
|
||||
|
@ -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()
|
||||
|
50
libstdc++-v3/testsuite/24_iterators/back_insert_iterator.cc
Normal file
50
libstdc++-v3/testsuite/24_iterators/back_insert_iterator.cc
Normal file
@ -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;
|
||||
}
|
50
libstdc++-v3/testsuite/24_iterators/front_insert_iterator.cc
Normal file
50
libstdc++-v3/testsuite/24_iterators/front_insert_iterator.cc
Normal file
@ -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;
|
||||
}
|
52
libstdc++-v3/testsuite/24_iterators/insert_iterator.cc
Normal file
52
libstdc++-v3/testsuite/24_iterators/insert_iterator.cc
Normal file
@ -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;
|
||||
}
|
53
libstdc++-v3/testsuite/24_iterators/reverse_iterator.cc
Normal file
53
libstdc++-v3/testsuite/24_iterators/reverse_iterator.cc
Normal file
@ -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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user