2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / libstdc++-v3 / include / backward / iterator.h
blob659176a73c5eca887e67fd82ee00745a01b0da49
1 /*
3 * Copyright (c) 1994
4 * Hewlett-Packard Company
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.
15 * Copyright (c) 1996
16 * Silicon Graphics Computer Systems, Inc.
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.
27 #ifndef _BACKWARD_ITERATOR_H
28 #define _BACKWARD_ITERATOR_H 1
30 #include "backward_warning.h"
31 #include "function.h"
32 #include <stddef.h>
33 #include "iostream.h"
34 #include <iterator>
36 #include <bits/stl_construct.h>
37 #include <bits/stl_raw_storage_iter.h>
39 #include <ext/iterator> // For 3-parameter distance extension
41 // Names from stl_iterator.h
42 using std::input_iterator_tag;
43 using std::output_iterator_tag;
44 using std::forward_iterator_tag;
45 using std::bidirectional_iterator_tag;
46 using std::random_access_iterator_tag;
48 #if 0
49 using std::iterator;
50 #endif
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.
56 template<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;
65 struct 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;
73 template<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;
82 template<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;
91 template<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;
100 using std::iterator_traits;
102 template <class _Iter>
103 inline typename iterator_traits<_Iter>::iterator_category
104 iterator_category(const _Iter& __i)
105 { return __iterator_category(__i); }
107 template <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); }
112 template<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); }
117 using std::distance;
118 using __gnu_cxx::distance; // 3-parameter extension
119 using std::advance;
121 using std::insert_iterator;
122 using std::front_insert_iterator;
123 using std::back_insert_iterator;
124 using std::inserter;
125 using std::front_inserter;
126 using std::back_inserter;
128 using std::reverse_iterator;
130 using std::istream_iterator;
131 using std::ostream_iterator;
133 // Names from stl_construct.h
134 template<class _T1, class _T2>
135 inline void
136 construct(_T1* __p, const _T2& __value)
137 { std::_Construct(__p, __value); }
139 template<class _T1>
140 inline void
141 construct(_T1* __p)
142 { std::_Construct(__p); }
144 template <class _Tp>
145 inline void
146 destroy(_Tp* __pointer)
147 { std::_Destroy(__pointer); }
149 template <class _ForwardIterator>
150 inline void
151 destroy(_ForwardIterator __first, _ForwardIterator __last)
152 { std::_Destroy(__first, __last); }
155 // Names from stl_raw_storage_iter.h
156 using std::raw_storage_iterator;
158 #endif /* _BACKWARD_ITERATOR_H */
160 // Local Variables:
161 // mode:C++
162 // End: