LTP GCOV extension - code coverage report
Current view: | directory - usr/include/c++/4.3/bits - stl_iterator_base_types.h
Test: | lcov.info
Date: | 2008-08-14 |  | Instrumented lines: | 3
Code covered: | 100.0 % |  | Executed lines: | 3

           1                 : // Types used in iterator implementation -*- C++ -*-
           2                 :
           3                 : // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
           4                 : // Free Software Foundation, Inc.
           5                 : //
           6                 : // This file is part of the GNU ISO C++ Library.  This library is free
           7                 : // software; you can redistribute it and/or modify it under the
           8                 : // terms of the GNU General Public License as published by the
           9                 : // Free Software Foundation; either version 2, or (at your option)
          10                 : // any later version.
          11                 :
          12                 : // This library is distributed in the hope that it will be useful,
          13                 : // but WITHOUT ANY WARRANTY; without even the implied warranty of
          14                 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
          15                 : // GNU General Public License for more details.
          16                 :
          17                 : // You should have received a copy of the GNU General Public License along
          18                 : // with this library; see the file COPYING.  If not, write to the Free
          19                 : // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
          20                 : // USA.
          21                 :
          22                 : // As a special exception, you may use this file as part of a free software
          23                 : // library without restriction.  Specifically, if other files instantiate
          24                 : // templates or use macros or inline functions from this file, or you compile
          25                 : // this file and link it with other files to produce an executable, this
          26                 : // file does not by itself cause the resulting executable to be covered by
          27                 : // the GNU General Public License.  This exception does not however
          28                 : // invalidate any other reasons why the executable file might be covered by
          29                 : // the GNU General Public License.
          30                 :
          31                 : /*
          32                 :  *
          33                 :  * Copyright (c) 1994
          34                 :  * Hewlett-Packard Company
          35                 :  *
          36                 :  * Permission to use, copy, modify, distribute and sell this software
          37                 :  * and its documentation for any purpose is hereby granted without fee,
          38                 :  * provided that the above copyright notice appear in all copies and
          39                 :  * that both that copyright notice and this permission notice appear
          40                 :  * in supporting documentation.  Hewlett-Packard Company makes no
          41                 :  * representations about the suitability of this software for any
          42                 :  * purpose.  It is provided "as is" without express or implied warranty.
          43                 :  *
          44                 :  *
          45                 :  * Copyright (c) 1996-1998
          46                 :  * Silicon Graphics Computer Systems, Inc.
          47                 :  *
          48                 :  * Permission to use, copy, modify, distribute and sell this software
          49                 :  * and its documentation for any purpose is hereby granted without fee,
          50                 :  * provided that the above copyright notice appear in all copies and
          51                 :  * that both that copyright notice and this permission notice appear
          52                 :  * in supporting documentation.  Silicon Graphics makes no
          53                 :  * representations about the suitability of this software for any
          54                 :  * purpose.  It is provided "as is" without express or implied warranty.
          55                 :  */
          56                 :
          57                 : /** @file stl_iterator_base_types.h
          58                 :  *  This is an internal header file, included by other library headers.
          59                 :  *  You should not attempt to use it directly.
          60                 :  *
          61                 :  *  This file contains all of the general iterator-related utility types,
          62                 :  *  such as iterator_traits and struct iterator.
          63                 :  */
          64                 :
          65                 : #ifndef _STL_ITERATOR_BASE_TYPES_H
          66                 : #define _STL_ITERATOR_BASE_TYPES_H 1
          67                 :
          68                 : #pragma GCC system_header
          69                 :
          70                 : #include <bits/c++config.h>
          71                 : #include <cstddef>
          72                 :
          73                 : _GLIBCXX_BEGIN_NAMESPACE(std)
          74                 :
          75                 :   //@{
          76                 :   /**
          77                 :    *  @defgroup iterator_tags Iterator Tags
          78                 :    *  These are empty types, used to distinguish different iterators.  The
          79                 :    *  distinction is not made by what they contain, but simply by what they
          80                 :    *  are.  Different underlying algorithms can then be used based on the
          81                 :    *  different operations supported by different iterator types.
          82                 :   */
          83                 :   ///  Marking input iterators.
          84                 :   struct input_iterator_tag {};
          85                 :   ///  Marking output iterators.
          86                 :   struct output_iterator_tag {};
          87                 :   /// Forward iterators support a superset of input iterator operations.
          88                 :   struct forward_iterator_tag : public input_iterator_tag {};
          89                 :   /// Bidirectional iterators support a superset of forward iterator
          90                 :   /// operations.
          91                 :   struct bidirectional_iterator_tag : public forward_iterator_tag {};
          92                 :   /// Random-access iterators support a superset of bidirectional iterator
          93                 :   /// operations.
          94                 :   struct random_access_iterator_tag : public bidirectional_iterator_tag {};
          95                 :   //@}
          96                 :
          97                 :
          98                 :   /**
          99                 :    *  @brief  Common %iterator class.
         100                 :    *
         101                 :    *  This class does nothing but define nested typedefs.  %Iterator classes
         102                 :    *  can inherit from this class to save some work.  The typedefs are then
         103                 :    *  used in specializations and overloading.
         104                 :    *
         105                 :    *  In particular, there are no default implementations of requirements
         106                 :    *  such as @c operator++ and the like.  (How could there be?)
         107                 :   */
         108                 :   template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
         109                 :            typename _Pointer = _Tp*, typename _Reference = _Tp&>
         110                 :     struct iterator
         111          304336 :     {
         112                 :       /// One of the @link iterator_tags tag types@endlink.
         113                 :       typedef _Category  iterator_category;
         114                 :       /// The type "pointed to" by the iterator.
         115                 :       typedef _Tp        value_type;
         116                 :       /// Distance between iterators is represented as this type.
         117                 :       typedef _Distance  difference_type;
         118                 :       /// This type represents a pointer-to-value_type.
         119                 :       typedef _Pointer   pointer;
         120                 :       /// This type represents a reference-to-value_type.
         121                 :       typedef _Reference reference;
         122                 :     };
         123                 :
         124                 :   /**
         125                 :    *  This class does nothing but define nested typedefs.  The general
         126                 :    *  version simply "forwards" the nested typedefs from the Iterator
         127                 :    *  argument.  Specialized versions for pointers and pointers-to-const
         128                 :    *  provide tighter, more correct semantics.
         129                 :   */
         130                 :   template<typename _Iterator>
         131                 :     struct iterator_traits
         132                 :     {
         133                 :       typedef typename _Iterator::iterator_category iterator_category;
         134                 :       typedef typename _Iterator::value_type        value_type;
         135                 :       typedef typename _Iterator::difference_type   difference_type;
         136                 :       typedef typename _Iterator::pointer           pointer;
         137                 :       typedef typename _Iterator::reference         reference;
         138                 :     };
         139                 :
         140                 :   template<typename _Tp>
         141                 :     struct iterator_traits<_Tp*>
         142                 :     {
         143                 :       typedef random_access_iterator_tag iterator_category;
         144                 :       typedef _Tp                         value_type;
         145                 :       typedef ptrdiff_t                   difference_type;
         146                 :       typedef _Tp*                        pointer;
         147                 :       typedef _Tp&                        reference;
         148                 :     };
         149                 :
         150                 :   template<typename _Tp>
         151                 :     struct iterator_traits<const _Tp*>
         152                 :     {
         153                 :       typedef random_access_iterator_tag iterator_category;
         154                 :       typedef _Tp                         value_type;
         155                 :       typedef ptrdiff_t                   difference_type;
         156                 :       typedef const _Tp*                  pointer;
         157                 :       typedef const _Tp&                  reference;
         158                 :     };
         159                 :
         160                 :   /**
         161                 :    *  This function is not a part of the C++ standard but is syntactic
         162                 :    *  sugar for internal library use only.
         163                 :   */
         164                 :   template<typename _Iter>
         165                 :     inline typename iterator_traits<_Iter>::iterator_category
         166            4730 :     __iterator_category(const _Iter&)
         167            4730 :     { return typename iterator_traits<_Iter>::iterator_category(); }
         168                 :
         169                 : _GLIBCXX_END_NAMESPACE
         170                 :
         171                 : #endif /* _STL_ITERATOR_BASE_TYPES_H */
         172                 :

Generated by: LTP GCOV extension version 1.6