2005-12-18 Benjamin Kosnik <bkoz@redhat.com>
[official-gcc.git] / libstdc++-v3 / include / backward / iterator.h
blob89496fb8fff4ea9efb44a41e7993374db518eb35
1 // Backward-compat support -*- C++ -*-
3 // Copyright (C) 2001, 2004 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
9 // any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 // USA.
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
32 * Copyright (c) 1994
33 * Hewlett-Packard Company
35 * Permission to use, copy, modify, distribute and sell this software
36 * and its documentation for any purpose is hereby granted without fee,
37 * provided that the above copyright notice appear in all copies and
38 * that both that copyright notice and this permission notice appear
39 * in supporting documentation. Hewlett-Packard Company makes no
40 * representations about the suitability of this software for any
41 * purpose. It is provided "as is" without express or implied warranty.
44 * Copyright (c) 1996
45 * Silicon Graphics Computer Systems, Inc.
47 * Permission to use, copy, modify, distribute and sell this software
48 * and its documentation for any purpose is hereby granted without fee,
49 * provided that the above copyright notice appear in all copies and
50 * that both that copyright notice and this permission notice appear
51 * in supporting documentation. Silicon Graphics makes no
52 * representations about the suitability of this software for any
53 * purpose. It is provided "as is" without express or implied warranty.
56 #ifndef _BACKWARD_ITERATOR_H
57 #define _BACKWARD_ITERATOR_H 1
59 #include "backward_warning.h"
60 #include "function.h"
61 #include <stddef.h>
62 #include "iostream.h"
63 #include <iterator>
65 #include <bits/stl_construct.h>
66 #include <bits/stl_raw_storage_iter.h>
68 #include <ext/iterator> // For 3-parameter distance extension
70 // Names from stl_iterator.h
71 using std::input_iterator_tag;
72 using std::output_iterator_tag;
73 using std::forward_iterator_tag;
74 using std::bidirectional_iterator_tag;
75 using std::random_access_iterator_tag;
77 #if 0
78 using std::iterator;
79 #endif
81 // The base classes input_iterator, output_iterator, forward_iterator,
82 // bidirectional_iterator, and random_access_iterator are not part of
83 // the C++ standard. (They have been replaced by struct iterator.)
84 // They are included for backward compatibility with the HP STL.
85 template<typename _Tp, typename _Distance>
86 struct input_iterator {
87 typedef input_iterator_tag iterator_category;
88 typedef _Tp value_type;
89 typedef _Distance difference_type;
90 typedef _Tp* pointer;
91 typedef _Tp& reference;
94 struct output_iterator {
95 typedef output_iterator_tag iterator_category;
96 typedef void value_type;
97 typedef void difference_type;
98 typedef void pointer;
99 typedef void reference;
102 template<typename _Tp, typename _Distance>
103 struct forward_iterator {
104 typedef forward_iterator_tag iterator_category;
105 typedef _Tp value_type;
106 typedef _Distance difference_type;
107 typedef _Tp* pointer;
108 typedef _Tp& reference;
111 template<typename _Tp, typename _Distance>
112 struct bidirectional_iterator {
113 typedef bidirectional_iterator_tag iterator_category;
114 typedef _Tp value_type;
115 typedef _Distance difference_type;
116 typedef _Tp* pointer;
117 typedef _Tp& reference;
120 template<typename _Tp, typename _Distance>
121 struct random_access_iterator {
122 typedef random_access_iterator_tag iterator_category;
123 typedef _Tp value_type;
124 typedef _Distance difference_type;
125 typedef _Tp* pointer;
126 typedef _Tp& reference;
129 using std::iterator_traits;
131 template <class _Iter>
132 inline typename iterator_traits<_Iter>::iterator_category
133 iterator_category(const _Iter& __i)
134 { return __iterator_category(__i); }
136 template <class _Iter>
137 inline typename iterator_traits<_Iter>::difference_type*
138 distance_type(const _Iter&)
139 { return static_cast<typename iterator_traits<_Iter>::difference_type*>(0); }
141 template<class _Iter>
142 inline typename iterator_traits<_Iter>::value_type*
143 value_type(const _Iter& __i)
144 { return static_cast<typename iterator_traits<_Iter>::value_type*>(0); }
146 using std::distance;
147 using __gnu_cxx::distance; // 3-parameter extension
148 using std::advance;
150 using std::insert_iterator;
151 using std::front_insert_iterator;
152 using std::back_insert_iterator;
153 using std::inserter;
154 using std::front_inserter;
155 using std::back_inserter;
157 using std::reverse_iterator;
159 using std::istream_iterator;
160 using std::ostream_iterator;
162 // Names from stl_construct.h
163 template<class _T1, class _T2>
164 inline void
165 construct(_T1* __p, const _T2& __value)
166 { std::_Construct(__p, __value); }
168 template<class _T1>
169 inline void
170 construct(_T1* __p)
171 { std::_Construct(__p); }
173 template <class _Tp>
174 inline void
175 destroy(_Tp* __pointer)
176 { std::_Destroy(__pointer); }
178 template <class _ForwardIterator>
179 inline void
180 destroy(_ForwardIterator __first, _ForwardIterator __last)
181 { std::_Destroy(__first, __last); }
184 // Names from stl_raw_storage_iter.h
185 using std::raw_storage_iterator;
187 #endif /* _BACKWARD_ITERATOR_H */