iterator.h revision 97403
1/*
2 *
3 * Copyright (c) 1994
4 * Hewlett-Packard Company
5 *
6 * Permission to use, copy, modify, distribute and sell this software
7 * and its documentation for any purpose is hereby granted without fee,
8 * provided that the above copyright notice appear in all copies and
9 * that both that copyright notice and this permission notice appear
10 * in supporting documentation.  Hewlett-Packard Company makes no
11 * representations about the suitability of this software for any
12 * purpose.  It is provided "as is" without express or implied warranty.
13 *
14 *
15 * Copyright (c) 1996
16 * Silicon Graphics Computer Systems, Inc.
17 *
18 * Permission to use, copy, modify, distribute and sell this software
19 * and its documentation for any purpose is hereby granted without fee,
20 * provided that the above copyright notice appear in all copies and
21 * that both that copyright notice and this permission notice appear
22 * in supporting documentation.  Silicon Graphics makes no
23 * representations about the suitability of this software for any
24 * purpose.  It is provided "as is" without express or implied warranty.
25 */
26
27#ifndef _CPP_BACKWARD_ITERATOR_H
28#define _CPP_BACKWARD_ITERATOR_H 1
29
30#include "backward_warning.h"
31#include "function.h"
32#include <stddef.h>
33#include "iostream.h"
34#include <iterator>
35
36#include <bits/stl_construct.h>
37#include <bits/stl_raw_storage_iter.h>
38
39#include <ext/iterator> // For 3-parameter distance extension
40
41// Names from stl_iterator.h
42using std::input_iterator_tag;
43using std::output_iterator_tag;
44using std::forward_iterator_tag;
45using std::bidirectional_iterator_tag;
46using std::random_access_iterator_tag;
47
48#if 0
49using std::iterator;
50#endif
51
52// The base classes input_iterator, output_iterator, forward_iterator,
53// bidirectional_iterator, and random_access_iterator are not part of
54// the C++ standard.  (They have been replaced by struct iterator.)
55// They are included for backward compatibility with the HP STL.
56template<typename _Tp, typename _Distance>
57  struct input_iterator {
58    typedef input_iterator_tag iterator_category;
59    typedef _Tp                value_type;
60    typedef _Distance          difference_type;
61    typedef _Tp*               pointer;
62    typedef _Tp&               reference;
63  };
64
65struct output_iterator {
66  typedef output_iterator_tag iterator_category;
67  typedef void                value_type;
68  typedef void                difference_type;
69  typedef void                pointer;
70  typedef void                reference;
71};
72
73template<typename _Tp, typename _Distance>
74  struct forward_iterator {
75    typedef forward_iterator_tag iterator_category;
76    typedef _Tp                  value_type;
77    typedef _Distance            difference_type;
78    typedef _Tp*                 pointer;
79    typedef _Tp&                 reference;
80  };
81
82template<typename _Tp, typename _Distance>
83  struct bidirectional_iterator {
84    typedef bidirectional_iterator_tag iterator_category;
85    typedef _Tp                        value_type;
86    typedef _Distance                  difference_type;
87    typedef _Tp*                       pointer;
88    typedef _Tp&                       reference;
89  };
90
91template<typename _Tp, typename _Distance>
92  struct random_access_iterator {
93    typedef random_access_iterator_tag iterator_category;
94    typedef _Tp                        value_type;
95    typedef _Distance                  difference_type;
96    typedef _Tp*                       pointer;
97    typedef _Tp&                       reference;
98  };
99
100using std::iterator_traits;
101
102template <class _Iter>
103  inline typename iterator_traits<_Iter>::iterator_category
104  iterator_category(const _Iter& __i)
105  { return __iterator_category(__i); }
106
107template <class _Iter>
108  inline typename iterator_traits<_Iter>::difference_type*
109  distance_type(const _Iter&)
110  { return static_cast<typename iterator_traits<_Iter>::difference_type*>(0); }
111
112template<class _Iter>
113  inline typename iterator_traits<_Iter>::value_type*
114  value_type(const _Iter& __i)
115  { return static_cast<typename iterator_traits<_Iter>::value_type*>(0); }
116
117using std::distance;
118using __gnu_cxx::distance; // 3-parameter extension
119using std::advance;
120
121using std::insert_iterator;
122using std::front_insert_iterator;
123using std::back_insert_iterator;
124using std::inserter;
125using std::front_inserter;
126using std::back_inserter;
127
128using std::reverse_iterator;
129
130using std::istream_iterator;
131using std::ostream_iterator;
132
133// Names from stl_construct.h
134template<class _T1, class _T2>
135  inline void
136  construct(_T1* __p, const _T2& __value)
137  { std::_Construct(__p, __value); }
138
139template<class _T1>
140  inline void
141  construct(_T1* __p)
142  { std::_Construct(__p); }
143
144template <class _Tp>
145  inline void
146  destroy(_Tp* __pointer)
147  { std::_Destroy(__pointer); }
148
149template <class _ForwardIterator>
150  inline void
151  destroy(_ForwardIterator __first, _ForwardIterator __last)
152  { std::_Destroy(__first, __last); }
153
154
155// Names from stl_raw_storage_iter.h
156using std::raw_storage_iterator;
157
158#endif /* _CPP_BACKWARD_ITERATOR_H */
159
160// Local Variables:
161// mode:C++
162// End:
163