1132720Skan// Backward-compat support -*- C++ -*- 2132720Skan 3132720Skan// Copyright (C) 2001, 2004 Free Software Foundation, Inc. 4132720Skan// 5132720Skan// This file is part of the GNU ISO C++ Library. This library is free 6132720Skan// software; you can redistribute it and/or modify it under the 7132720Skan// terms of the GNU General Public License as published by the 8132720Skan// Free Software Foundation; either version 2, or (at your option) 9132720Skan// any later version. 10132720Skan 11132720Skan// This library is distributed in the hope that it will be useful, 12132720Skan// but WITHOUT ANY WARRANTY; without even the implied warranty of 13132720Skan// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14132720Skan// GNU General Public License for more details. 15132720Skan 16132720Skan// You should have received a copy of the GNU General Public License along 17132720Skan// with this library; see the file COPYING. If not, write to the Free 18169691Skan// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 19132720Skan// USA. 20132720Skan 21132720Skan// As a special exception, you may use this file as part of a free software 22132720Skan// library without restriction. Specifically, if other files instantiate 23132720Skan// templates or use macros or inline functions from this file, or you compile 24132720Skan// this file and link it with other files to produce an executable, this 25132720Skan// file does not by itself cause the resulting executable to be covered by 26132720Skan// the GNU General Public License. This exception does not however 27132720Skan// invalidate any other reasons why the executable file might be covered by 28132720Skan// the GNU General Public License. 29132720Skan 3097403Sobrien/* 3197403Sobrien * 3297403Sobrien * Copyright (c) 1994 3397403Sobrien * Hewlett-Packard Company 3497403Sobrien * 3597403Sobrien * Permission to use, copy, modify, distribute and sell this software 3697403Sobrien * and its documentation for any purpose is hereby granted without fee, 3797403Sobrien * provided that the above copyright notice appear in all copies and 3897403Sobrien * that both that copyright notice and this permission notice appear 3997403Sobrien * in supporting documentation. Hewlett-Packard Company makes no 4097403Sobrien * representations about the suitability of this software for any 4197403Sobrien * purpose. It is provided "as is" without express or implied warranty. 4297403Sobrien * 4397403Sobrien * 4497403Sobrien * Copyright (c) 1996 4597403Sobrien * Silicon Graphics Computer Systems, Inc. 4697403Sobrien * 4797403Sobrien * Permission to use, copy, modify, distribute and sell this software 4897403Sobrien * and its documentation for any purpose is hereby granted without fee, 4997403Sobrien * provided that the above copyright notice appear in all copies and 5097403Sobrien * that both that copyright notice and this permission notice appear 5197403Sobrien * in supporting documentation. Silicon Graphics makes no 5297403Sobrien * representations about the suitability of this software for any 5397403Sobrien * purpose. It is provided "as is" without express or implied warranty. 5497403Sobrien */ 5597403Sobrien 56132720Skan#ifndef _BACKWARD_ITERATOR_H 57132720Skan#define _BACKWARD_ITERATOR_H 1 5897403Sobrien 5997403Sobrien#include "backward_warning.h" 6097403Sobrien#include "function.h" 6197403Sobrien#include <stddef.h> 6297403Sobrien#include "iostream.h" 6397403Sobrien#include <iterator> 6497403Sobrien 6597403Sobrien#include <bits/stl_construct.h> 6697403Sobrien#include <bits/stl_raw_storage_iter.h> 6797403Sobrien 6897403Sobrien#include <ext/iterator> // For 3-parameter distance extension 6997403Sobrien 7097403Sobrien// Names from stl_iterator.h 7197403Sobrienusing std::input_iterator_tag; 7297403Sobrienusing std::output_iterator_tag; 7397403Sobrienusing std::forward_iterator_tag; 7497403Sobrienusing std::bidirectional_iterator_tag; 7597403Sobrienusing std::random_access_iterator_tag; 7697403Sobrien 7797403Sobrien#if 0 7897403Sobrienusing std::iterator; 7997403Sobrien#endif 8097403Sobrien 8197403Sobrien// The base classes input_iterator, output_iterator, forward_iterator, 8297403Sobrien// bidirectional_iterator, and random_access_iterator are not part of 8397403Sobrien// the C++ standard. (They have been replaced by struct iterator.) 8497403Sobrien// They are included for backward compatibility with the HP STL. 8597403Sobrientemplate<typename _Tp, typename _Distance> 8697403Sobrien struct input_iterator { 8797403Sobrien typedef input_iterator_tag iterator_category; 8897403Sobrien typedef _Tp value_type; 8997403Sobrien typedef _Distance difference_type; 9097403Sobrien typedef _Tp* pointer; 9197403Sobrien typedef _Tp& reference; 9297403Sobrien }; 9397403Sobrien 9497403Sobrienstruct output_iterator { 9597403Sobrien typedef output_iterator_tag iterator_category; 9697403Sobrien typedef void value_type; 9797403Sobrien typedef void difference_type; 9897403Sobrien typedef void pointer; 9997403Sobrien typedef void reference; 10097403Sobrien}; 10197403Sobrien 10297403Sobrientemplate<typename _Tp, typename _Distance> 10397403Sobrien struct forward_iterator { 10497403Sobrien typedef forward_iterator_tag iterator_category; 10597403Sobrien typedef _Tp value_type; 10697403Sobrien typedef _Distance difference_type; 10797403Sobrien typedef _Tp* pointer; 10897403Sobrien typedef _Tp& reference; 10997403Sobrien }; 11097403Sobrien 11197403Sobrientemplate<typename _Tp, typename _Distance> 11297403Sobrien struct bidirectional_iterator { 11397403Sobrien typedef bidirectional_iterator_tag iterator_category; 11497403Sobrien typedef _Tp value_type; 11597403Sobrien typedef _Distance difference_type; 11697403Sobrien typedef _Tp* pointer; 11797403Sobrien typedef _Tp& reference; 11897403Sobrien }; 11997403Sobrien 12097403Sobrientemplate<typename _Tp, typename _Distance> 12197403Sobrien struct random_access_iterator { 12297403Sobrien typedef random_access_iterator_tag iterator_category; 12397403Sobrien typedef _Tp value_type; 12497403Sobrien typedef _Distance difference_type; 12597403Sobrien typedef _Tp* pointer; 12697403Sobrien typedef _Tp& reference; 12797403Sobrien }; 12897403Sobrien 12997403Sobrienusing std::iterator_traits; 13097403Sobrien 13197403Sobrientemplate <class _Iter> 13297403Sobrien inline typename iterator_traits<_Iter>::iterator_category 13397403Sobrien iterator_category(const _Iter& __i) 13497403Sobrien { return __iterator_category(__i); } 13597403Sobrien 13697403Sobrientemplate <class _Iter> 13797403Sobrien inline typename iterator_traits<_Iter>::difference_type* 13897403Sobrien distance_type(const _Iter&) 13997403Sobrien { return static_cast<typename iterator_traits<_Iter>::difference_type*>(0); } 14097403Sobrien 14197403Sobrientemplate<class _Iter> 14297403Sobrien inline typename iterator_traits<_Iter>::value_type* 14397403Sobrien value_type(const _Iter& __i) 14497403Sobrien { return static_cast<typename iterator_traits<_Iter>::value_type*>(0); } 14597403Sobrien 14697403Sobrienusing std::distance; 14797403Sobrienusing __gnu_cxx::distance; // 3-parameter extension 148132720Skanusing std::advance; 14997403Sobrien 15097403Sobrienusing std::insert_iterator; 15197403Sobrienusing std::front_insert_iterator; 15297403Sobrienusing std::back_insert_iterator; 15397403Sobrienusing std::inserter; 15497403Sobrienusing std::front_inserter; 15597403Sobrienusing std::back_inserter; 15697403Sobrien 15797403Sobrienusing std::reverse_iterator; 15897403Sobrien 15997403Sobrienusing std::istream_iterator; 16097403Sobrienusing std::ostream_iterator; 16197403Sobrien 16297403Sobrien// Names from stl_construct.h 16397403Sobrientemplate<class _T1, class _T2> 16497403Sobrien inline void 16597403Sobrien construct(_T1* __p, const _T2& __value) 16697403Sobrien { std::_Construct(__p, __value); } 16797403Sobrien 16897403Sobrientemplate<class _T1> 16997403Sobrien inline void 17097403Sobrien construct(_T1* __p) 17197403Sobrien { std::_Construct(__p); } 17297403Sobrien 17397403Sobrientemplate <class _Tp> 17497403Sobrien inline void 17597403Sobrien destroy(_Tp* __pointer) 17697403Sobrien { std::_Destroy(__pointer); } 177132720Skan 17897403Sobrientemplate <class _ForwardIterator> 17997403Sobrien inline void 18097403Sobrien destroy(_ForwardIterator __first, _ForwardIterator __last) 18197403Sobrien { std::_Destroy(__first, __last); } 18297403Sobrien 18397403Sobrien 18497403Sobrien// Names from stl_raw_storage_iter.h 18597403Sobrienusing std::raw_storage_iterator; 18697403Sobrien 187132720Skan#endif /* _BACKWARD_ITERATOR_H */ 188