59 #ifndef _STL_ITERATOR_BASE_FUNCS_H
60 #define _STL_ITERATOR_BASE_FUNCS_H 1
62 #pragma GCC system_header
68 namespace std _GLIBCXX_VISIBILITY(default)
70 _GLIBCXX_BEGIN_NAMESPACE_VERSION
72 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
74 template <
typename>
struct _List_iterator;
75 template <
typename>
struct _List_const_iterator;
76 _GLIBCXX_END_NAMESPACE_CONTAINER
78 template<
typename _InputIterator>
79 inline _GLIBCXX14_CONSTEXPR
80 typename iterator_traits<_InputIterator>::difference_type
81 __distance(_InputIterator __first, _InputIterator __last,
85 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
87 typename iterator_traits<_InputIterator>::difference_type __n = 0;
88 while (__first != __last)
96 template<
typename _RandomAccessIterator>
97 inline _GLIBCXX14_CONSTEXPR
98 typename iterator_traits<_RandomAccessIterator>::difference_type
99 __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
100 random_access_iterator_tag)
103 __glibcxx_function_requires(_RandomAccessIteratorConcept<
104 _RandomAccessIterator>)
105 return __last - __first;
108 #if _GLIBCXX_USE_CXX11_ABI
110 template<
typename _Tp>
112 __distance(_GLIBCXX_STD_C::_List_iterator<_Tp>,
113 _GLIBCXX_STD_C::_List_iterator<_Tp>,
116 template<
typename _Tp>
118 __distance(_GLIBCXX_STD_C::_List_const_iterator<_Tp>,
119 _GLIBCXX_STD_C::_List_const_iterator<_Tp>,
123 #if __cplusplus >= 201103L
125 template<
typename _OutputIterator>
127 __distance(_OutputIterator, _OutputIterator, output_iterator_tag) =
delete;
143 template<
typename _InputIterator>
145 inline _GLIBCXX17_CONSTEXPR
146 typename iterator_traits<_InputIterator>::difference_type
147 distance(_InputIterator __first, _InputIterator __last)
150 return std::__distance(__first, __last,
154 template<
typename _InputIterator,
typename _Distance>
155 inline _GLIBCXX14_CONSTEXPR
void
156 __advance(_InputIterator& __i, _Distance __n, input_iterator_tag)
159 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
160 __glibcxx_assert(__n >= 0);
165 template<
typename _B
idirectionalIterator,
typename _Distance>
166 inline _GLIBCXX14_CONSTEXPR
void
167 __advance(_BidirectionalIterator& __i, _Distance __n,
168 bidirectional_iterator_tag)
171 __glibcxx_function_requires(_BidirectionalIteratorConcept<
172 _BidirectionalIterator>)
181 template<typename _RandomAccessIterator, typename _Distance>
182 inline _GLIBCXX14_CONSTEXPR
void
183 __advance(_RandomAccessIterator& __i, _Distance __n,
184 random_access_iterator_tag)
187 __glibcxx_function_requires(_RandomAccessIteratorConcept<
188 _RandomAccessIterator>)
189 if (__builtin_constant_p(__n) && __n == 1)
191 else if (__builtin_constant_p(__n) && __n == -1)
197 #if __cplusplus >= 201103L
199 template<
typename _OutputIterator,
typename _Distance>
201 __advance(_OutputIterator&, _Distance, output_iterator_tag) =
delete;
216 template<
typename _InputIterator,
typename _Distance>
217 inline _GLIBCXX17_CONSTEXPR
void
225 #if __cplusplus >= 201103L
227 template<
typename _InputIterator>
229 inline _GLIBCXX17_CONSTEXPR _InputIterator
230 next(_InputIterator __x,
typename
231 iterator_traits<_InputIterator>::difference_type __n = 1)
234 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
239 template<
typename _B
idirectionalIterator>
241 inline _GLIBCXX17_CONSTEXPR _BidirectionalIterator
242 prev(_BidirectionalIterator __x,
typename
243 iterator_traits<_BidirectionalIterator>::difference_type __n = 1)
246 __glibcxx_function_requires(_BidirectionalIteratorConcept<
247 _BidirectionalIterator>)
254 _GLIBCXX_END_NAMESPACE_VERSION
constexpr iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)
ISO C++ entities toplevel namespace is std.
constexpr iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
constexpr void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
Traits class for iterators.