1 // Backward-compat support -*- C++ -*- 2 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. 10 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. 15 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. 20 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. 29 30 /* 31 * 32 * Copyright (c) 1994 33 * Hewlett-Packard Company 34 * 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. 42 * 43 * 44 * Copyright (c) 1996 45 * Silicon Graphics Computer Systems, Inc. 46 * 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. 54 */ 55 56 #ifndef _BACKWARD_ITERATOR_H 57 #define _BACKWARD_ITERATOR_H 1 58 59 #include "backward_warning.h" 60 #include "function.h" 61 #include <stddef.h> 62 #include "iostream.h" 63 #include <iterator> 64 65 #include <bits/stl_construct.h> 66 #include <bits/stl_raw_storage_iter.h> 67 68 #include <ext/iterator> // For 3-parameter distance extension 69 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; 76 77 #if 0 78 using std::iterator; 79 #endif 80 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; 92 }; 93 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; 100 }; 101 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; 109 }; 110 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; 118 }; 119 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; 127 }; 128 129 using std::iterator_traits; 130 131 template <class _Iter> 132 inline typename iterator_traits<_Iter>::iterator_category 133 iterator_category(const _Iter& __i) 134 { return __iterator_category(__i); } 135 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); } 140 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); } 145 146 using std::distance; 147 using __gnu_cxx::distance; // 3-parameter extension 148 using std::advance; 149 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; 156 157 using std::reverse_iterator; 158 159 using std::istream_iterator; 160 using std::ostream_iterator; 161 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); } 167 168 template<class _T1> 169 inline void 170 construct(_T1* __p) 171 { std::_Construct(__p); } 172 173 template <class _Tp> 174 inline void 175 destroy(_Tp* __pointer) 176 { std::_Destroy(__pointer); } 177 178 template <class _ForwardIterator> 179 inline void 180 destroy(_ForwardIterator __first, _ForwardIterator __last) 181 { std::_Destroy(__first, __last); } 182 183 184 // Names from stl_raw_storage_iter.h 185 using std::raw_storage_iterator; 186 187 #endif /* _BACKWARD_ITERATOR_H */ 188