59 #ifndef _STL_ITERATOR_BASE_FUNCS_H 60 #define _STL_ITERATOR_BASE_FUNCS_H 1 62 #pragma GCC system_header 67 namespace std _GLIBCXX_VISIBILITY(default)
69 _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
73 _GLIBCXX_END_NAMESPACE_CONTAINER
75 _GLIBCXX_BEGIN_NAMESPACE_VERSION
77 template<
typename _InputIterator>
78 inline typename iterator_traits<_InputIterator>::difference_type
79 __distance(_InputIterator __first, _InputIterator __last,
83 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
85 typename iterator_traits<_InputIterator>::difference_type __n = 0;
86 while (__first != __last)
94 template<
typename _RandomAccessIterator>
95 inline typename iterator_traits<_RandomAccessIterator>::difference_type
96 __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
100 __glibcxx_function_requires(_RandomAccessIteratorConcept<
101 _RandomAccessIterator>)
102 return __last - __first;
105 #if _GLIBCXX_USE_CXX11_ABI 107 template<
typename _Tp>
109 __distance(_GLIBCXX_STD_C::_List_iterator<_Tp>,
110 _GLIBCXX_STD_C::_List_iterator<_Tp>,
113 template<
typename _Tp>
115 __distance(_GLIBCXX_STD_C::_List_const_iterator<_Tp>,
116 _GLIBCXX_STD_C::_List_const_iterator<_Tp>,
133 template<
typename _InputIterator>
134 inline typename iterator_traits<_InputIterator>::difference_type
135 distance(_InputIterator __first, _InputIterator __last)
138 return std::__distance(__first, __last,
142 template<
typename _InputIterator,
typename _Distance>
147 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
148 __glibcxx_assert(__n >= 0);
153 template<
typename _B
idirectionalIterator,
typename _Distance>
155 __advance(_BidirectionalIterator& __i, _Distance __n,
159 __glibcxx_function_requires(_BidirectionalIteratorConcept<
160 _BidirectionalIterator>)
169 template<
typename _RandomAccessIterator,
typename _Distance>
171 __advance(_RandomAccessIterator& __i, _Distance __n,
175 __glibcxx_function_requires(_RandomAccessIteratorConcept<
176 _RandomAccessIterator>)
192 template<
typename _InputIterator,
typename _Distance>
197 typename iterator_traits<_InputIterator>::difference_type __d = __n;
201 #if __cplusplus >= 201103L 203 template<
typename _ForwardIterator>
204 inline _ForwardIterator
205 next(_ForwardIterator __x,
typename 206 iterator_traits<_ForwardIterator>::difference_type __n = 1)
209 __glibcxx_function_requires(_ForwardIteratorConcept<
215 template<
typename _B
idirectionalIterator>
216 inline _BidirectionalIterator
217 prev(_BidirectionalIterator __x,
typename 218 iterator_traits<_BidirectionalIterator>::difference_type __n = 1)
221 __glibcxx_function_requires(_BidirectionalIteratorConcept<
222 _BidirectionalIterator>)
229 _GLIBCXX_END_NAMESPACE_VERSION
Bidirectional iterators support a superset of forward iterator operations.
void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
Random-access iterators support a superset of bidirectional iterator operations.
ISO C++ entities toplevel namespace is std.
iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)