ext/iterator

Go to the documentation of this file.
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 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
00065 
00066   // There are two signatures for distance.  In addition to the one
00067   // taking two iterators and returning a result, there is another
00068   // taking two iterators and a reference-to-result variable, and
00069   // returning nothing.  The latter seems to be an SGI extension.
00070   // -- pedwards
00071   template<typename _InputIterator, typename _Distance>
00072     inline void
00073     __distance(_InputIterator __first, _InputIterator __last,
00074            _Distance& __n, std::input_iterator_tag)
00075     {
00076       // concept requirements
00077       __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
00078       while (__first != __last)
00079     {
00080       ++__first;
00081       ++__n;
00082     }
00083     }
00084 
00085   template<typename _RandomAccessIterator, typename _Distance>
00086     inline void
00087     __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
00088            _Distance& __n, std::random_access_iterator_tag)
00089     {
00090       // concept requirements
00091       __glibcxx_function_requires(_RandomAccessIteratorConcept<
00092                   _RandomAccessIterator>)
00093       __n += __last - __first;
00094     }
00095 
00096   /**
00097    *  This is an SGI extension.
00098    *  @ingroup SGIextensions
00099    *  @doctodo
00100   */
00101   template<typename _InputIterator, typename _Distance>
00102     inline void
00103     distance(_InputIterator __first, _InputIterator __last,
00104              _Distance& __n)
00105     {
00106       // concept requirements -- taken care of in __distance
00107       __distance(__first, __last, __n, std::__iterator_category(__first));
00108     }
00109 
00110 _GLIBCXX_END_NAMESPACE
00111 
00112 #endif
00113 

Generated on Thu Jul 23 21:16:09 2009 for libstdc++ by  doxygen 1.5.8