libstdc++
|
00001 // HP/SGI iterator extensions -*- C++ -*- 00002 00003 // Copyright (C) 2001, 2002, 2004, 2005, 2009 Free Software Foundation, Inc. 00004 // 00005 // This file is part of the GNU ISO C++ Library. This library is free 00006 // software; you can redistribute it and/or modify it under the 00007 // terms of the GNU General Public License as published by the 00008 // Free Software Foundation; either version 3, or (at your option) 00009 // any later version. 00010 00011 // This library is distributed in the hope that it will be useful, 00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 // GNU General Public License for more details. 00015 00016 // Under Section 7 of GPL version 3, you are granted additional 00017 // permissions described in the GCC Runtime Library Exception, version 00018 // 3.1, as published by the Free Software Foundation. 00019 00020 // You should have received a copy of the GNU General Public License and 00021 // a copy of the GCC Runtime Library Exception along with this program; 00022 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 00023 // <http://www.gnu.org/licenses/>. 00024 00025 /* 00026 * 00027 * Copyright (c) 1994 00028 * Hewlett-Packard Company 00029 * 00030 * Permission to use, copy, modify, distribute and sell this software 00031 * and its documentation for any purpose is hereby granted without fee, 00032 * provided that the above copyright notice appear in all copies and 00033 * that both that copyright notice and this permission notice appear 00034 * in supporting documentation. Hewlett-Packard Company makes no 00035 * representations about the suitability of this software for any 00036 * purpose. It is provided "as is" without express or implied warranty. 00037 * 00038 * 00039 * Copyright (c) 1996-1998 00040 * Silicon Graphics Computer Systems, Inc. 00041 * 00042 * Permission to use, copy, modify, distribute and sell this software 00043 * and its documentation for any purpose is hereby granted without fee, 00044 * provided that the above copyright notice appear in all copies and 00045 * that both that copyright notice and this permission notice appear 00046 * in supporting documentation. Silicon Graphics makes no 00047 * representations about the suitability of this software for any 00048 * purpose. It is provided "as is" without express or implied warranty. 00049 */ 00050 00051 /** @file ext/iterator 00052 * This file is a GNU extension to the Standard C++ Library (possibly 00053 * containing extensions from the HP/SGI STL subset). 00054 */ 00055 00056 #ifndef _EXT_ITERATOR 00057 #define _EXT_ITERATOR 1 00058 00059 #pragma GCC system_header 00060 00061 #include <bits/concept_check.h> 00062 #include <iterator> 00063 00064 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) 00065 { 00066 _GLIBCXX_BEGIN_NAMESPACE_VERSION 00067 00068 // There are two signatures for distance. In addition to the one 00069 // taking two iterators and returning a result, there is another 00070 // taking two iterators and a reference-to-result variable, and 00071 // returning nothing. The latter seems to be an SGI extension. 00072 // -- pedwards 00073 template<typename _InputIterator, typename _Distance> 00074 inline void 00075 __distance(_InputIterator __first, _InputIterator __last, 00076 _Distance& __n, std::input_iterator_tag) 00077 { 00078 // concept requirements 00079 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>) 00080 while (__first != __last) 00081 { 00082 ++__first; 00083 ++__n; 00084 } 00085 } 00086 00087 template<typename _RandomAccessIterator, typename _Distance> 00088 inline void 00089 __distance(_RandomAccessIterator __first, _RandomAccessIterator __last, 00090 _Distance& __n, std::random_access_iterator_tag) 00091 { 00092 // concept requirements 00093 __glibcxx_function_requires(_RandomAccessIteratorConcept< 00094 _RandomAccessIterator>) 00095 __n += __last - __first; 00096 } 00097 00098 /** 00099 * This is an SGI extension. 00100 * @ingroup SGIextensions 00101 * @doctodo 00102 */ 00103 template<typename _InputIterator, typename _Distance> 00104 inline void 00105 distance(_InputIterator __first, _InputIterator __last, 00106 _Distance& __n) 00107 { 00108 // concept requirements -- taken care of in __distance 00109 __distance(__first, __last, __n, std::__iterator_category(__first)); 00110 } 00111 00112 _GLIBCXX_END_NAMESPACE_VERSION 00113 } // namespace 00114 00115 #endif 00116