OpenCores
URL https://opencores.org/ocsvn/altor32/altor32/trunk

Subversion Repositories altor32

[/] [altor32/] [trunk/] [gcc-x64/] [or1knd-elf/] [or1knd-elf/] [include/] [c++/] [4.8.0/] [bits/] [stl_iterator_base_types.h] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 ultra_embe
// Types used in iterator implementation -*- C++ -*-
2
 
3
// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009,
4
// 2010, 2011, 2012
5
// Free Software Foundation, Inc.
6
//
7
// This file is part of the GNU ISO C++ Library.  This library is free
8
// software; you can redistribute it and/or modify it under the
9
// terms of the GNU General Public License as published by the
10
// Free Software Foundation; either version 3, or (at your option)
11
// any later version.
12
 
13
// This library is distributed in the hope that it will be useful,
14
// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
// GNU General Public License for more details.
17
 
18
// Under Section 7 of GPL version 3, you are granted additional
19
// permissions described in the GCC Runtime Library Exception, version
20
// 3.1, as published by the Free Software Foundation.
21
 
22
// You should have received a copy of the GNU General Public License and
23
// a copy of the GCC Runtime Library Exception along with this program;
24
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
25
// <http://www.gnu.org/licenses/>.
26
 
27
/*
28
 *
29
 * Copyright (c) 1994
30
 * Hewlett-Packard Company
31
 *
32
 * Permission to use, copy, modify, distribute and sell this software
33
 * and its documentation for any purpose is hereby granted without fee,
34
 * provided that the above copyright notice appear in all copies and
35
 * that both that copyright notice and this permission notice appear
36
 * in supporting documentation.  Hewlett-Packard Company makes no
37
 * representations about the suitability of this software for any
38
 * purpose.  It is provided "as is" without express or implied warranty.
39
 *
40
 *
41
 * Copyright (c) 1996-1998
42
 * Silicon Graphics Computer Systems, Inc.
43
 *
44
 * Permission to use, copy, modify, distribute and sell this software
45
 * and its documentation for any purpose is hereby granted without fee,
46
 * provided that the above copyright notice appear in all copies and
47
 * that both that copyright notice and this permission notice appear
48
 * in supporting documentation.  Silicon Graphics makes no
49
 * representations about the suitability of this software for any
50
 * purpose.  It is provided "as is" without express or implied warranty.
51
 */
52
 
53
/** @file bits/stl_iterator_base_types.h
54
 *  This is an internal header file, included by other library headers.
55
 *  Do not attempt to use it directly. @headername{iterator}
56
 *
57
 *  This file contains all of the general iterator-related utility types,
58
 *  such as iterator_traits and struct iterator.
59
 */
60
 
61
#ifndef _STL_ITERATOR_BASE_TYPES_H
62
#define _STL_ITERATOR_BASE_TYPES_H 1
63
 
64
#pragma GCC system_header
65
 
66
#include <bits/c++config.h>
67
 
68
#if __cplusplus >= 201103L
69
# include <type_traits>  // For _GLIBCXX_HAS_NESTED_TYPE, is_convertible
70
#endif
71
 
72
namespace std _GLIBCXX_VISIBILITY(default)
73
{
74
_GLIBCXX_BEGIN_NAMESPACE_VERSION
75
 
76
  /**
77
   *  @defgroup iterators Iterators
78
   *  Abstractions for uniform iterating through various underlying types.
79
  */
80
  //@{ 
81
 
82
  /**
83
   *  @defgroup iterator_tags Iterator Tags
84
   *  These are empty types, used to distinguish different iterators.  The
85
   *  distinction is not made by what they contain, but simply by what they
86
   *  are.  Different underlying algorithms can then be used based on the
87
   *  different operations supported by different iterator types.
88
  */
89
  //@{ 
90
  ///  Marking input iterators.
91
  struct input_iterator_tag { };
92
 
93
  ///  Marking output iterators.
94
  struct output_iterator_tag { };
95
 
96
  /// Forward iterators support a superset of input iterator operations.
97
  struct forward_iterator_tag : public input_iterator_tag { };
98
 
99
  /// Bidirectional iterators support a superset of forward iterator
100
  /// operations.
101
  struct bidirectional_iterator_tag : public forward_iterator_tag { };
102
 
103
  /// Random-access iterators support a superset of bidirectional
104
  /// iterator operations.
105
  struct random_access_iterator_tag : public bidirectional_iterator_tag { };
106
  //@}
107
 
108
  /**
109
   *  @brief  Common %iterator class.
110
   *
111
   *  This class does nothing but define nested typedefs.  %Iterator classes
112
   *  can inherit from this class to save some work.  The typedefs are then
113
   *  used in specializations and overloading.
114
   *
115
   *  In particular, there are no default implementations of requirements
116
   *  such as @c operator++ and the like.  (How could there be?)
117
  */
118
  template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
119
           typename _Pointer = _Tp*, typename _Reference = _Tp&>
120
    struct iterator
121
    {
122
      /// One of the @link iterator_tags tag types@endlink.
123
      typedef _Category  iterator_category;
124
      /// The type "pointed to" by the iterator.
125
      typedef _Tp        value_type;
126
      /// Distance between iterators is represented as this type.
127
      typedef _Distance  difference_type;
128
      /// This type represents a pointer-to-value_type.
129
      typedef _Pointer   pointer;
130
      /// This type represents a reference-to-value_type.
131
      typedef _Reference reference;
132
    };
133
 
134
  /**
135
   *  @brief  Traits class for iterators.
136
   *
137
   *  This class does nothing but define nested typedefs.  The general
138
   *  version simply @a forwards the nested typedefs from the Iterator
139
   *  argument.  Specialized versions for pointers and pointers-to-const
140
   *  provide tighter, more correct semantics.
141
  */
142
#if __cplusplus >= 201103L
143
 
144
_GLIBCXX_HAS_NESTED_TYPE(iterator_category)
145
 
146
  template<typename _Iterator,
147
           bool = __has_iterator_category<_Iterator>::value>
148
    struct __iterator_traits { };
149
 
150
  template<typename _Iterator>
151
    struct __iterator_traits<_Iterator, true>
152
    {
153
      typedef typename _Iterator::iterator_category iterator_category;
154
      typedef typename _Iterator::value_type        value_type;
155
      typedef typename _Iterator::difference_type   difference_type;
156
      typedef typename _Iterator::pointer           pointer;
157
      typedef typename _Iterator::reference         reference;
158
    };
159
 
160
  template<typename _Iterator>
161
    struct iterator_traits
162
    : public __iterator_traits<_Iterator> { };
163
#else
164
  template<typename _Iterator>
165
    struct iterator_traits
166
    {
167
      typedef typename _Iterator::iterator_category iterator_category;
168
      typedef typename _Iterator::value_type        value_type;
169
      typedef typename _Iterator::difference_type   difference_type;
170
      typedef typename _Iterator::pointer           pointer;
171
      typedef typename _Iterator::reference         reference;
172
    };
173
#endif
174
 
175
  /// Partial specialization for pointer types.
176
  template<typename _Tp>
177
    struct iterator_traits<_Tp*>
178
    {
179
      typedef random_access_iterator_tag iterator_category;
180
      typedef _Tp                         value_type;
181
      typedef ptrdiff_t                   difference_type;
182
      typedef _Tp*                        pointer;
183
      typedef _Tp&                        reference;
184
    };
185
 
186
  /// Partial specialization for const pointer types.
187
  template<typename _Tp>
188
    struct iterator_traits<const _Tp*>
189
    {
190
      typedef random_access_iterator_tag iterator_category;
191
      typedef _Tp                         value_type;
192
      typedef ptrdiff_t                   difference_type;
193
      typedef const _Tp*                  pointer;
194
      typedef const _Tp&                  reference;
195
    };
196
 
197
  /**
198
   *  This function is not a part of the C++ standard but is syntactic
199
   *  sugar for internal library use only.
200
  */
201
  template<typename _Iter>
202
    inline typename iterator_traits<_Iter>::iterator_category
203
    __iterator_category(const _Iter&)
204
    { return typename iterator_traits<_Iter>::iterator_category(); }
205
 
206
  //@}
207
 
208
  // If _Iterator has a base returns it otherwise _Iterator is returned
209
  // untouched
210
  template<typename _Iterator, bool _HasBase>
211
    struct _Iter_base
212
    {
213
      typedef _Iterator iterator_type;
214
      static iterator_type _S_base(_Iterator __it)
215
      { return __it; }
216
    };
217
 
218
  template<typename _Iterator>
219
    struct _Iter_base<_Iterator, true>
220
    {
221
      typedef typename _Iterator::iterator_type iterator_type;
222
      static iterator_type _S_base(_Iterator __it)
223
      { return __it.base(); }
224
    };
225
 
226
#if __cplusplus >= 201103L
227
  template<typename _InIter>
228
    using _RequireInputIter = typename
229
      enable_if<is_convertible<typename
230
                iterator_traits<_InIter>::iterator_category,
231
                               input_iterator_tag>::value>::type;
232
#endif
233
 
234
_GLIBCXX_END_NAMESPACE_VERSION
235
} // namespace
236
 
237
#endif /* _STL_ITERATOR_BASE_TYPES_H */
238
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.