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_VERSION
71 template<
typename _InputIterator>
72 inline typename iterator_traits<_InputIterator>::difference_type
73 __distance(_InputIterator __first, _InputIterator __last,
77 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
79 typename iterator_traits<_InputIterator>::difference_type __n = 0;
80 while (__first != __last)
88 template<
typename _RandomAccessIterator>
89 inline typename iterator_traits<_RandomAccessIterator>::difference_type
90 __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
91 random_access_iterator_tag)
94 __glibcxx_function_requires(_RandomAccessIteratorConcept<
95 _RandomAccessIterator>)
96 return __last - __first;
112 template<typename _InputIterator>
113 inline typename iterator_traits<_InputIterator>::difference_type
114 distance(_InputIterator __first, _InputIterator __last)
117 return std::__distance(__first, __last,
121 template<
typename _InputIterator,
typename _Distance>
123 __advance(_InputIterator& __i, _Distance __n, input_iterator_tag)
126 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
127 _GLIBCXX_DEBUG_ASSERT(__n >= 0);
132 template<typename _BidirectionalIterator, typename _Distance>
134 __advance(_BidirectionalIterator& __i, _Distance __n,
135 bidirectional_iterator_tag)
138 __glibcxx_function_requires(_BidirectionalIteratorConcept<
139 _BidirectionalIterator>)
148 template<typename _RandomAccessIterator, typename _Distance>
150 __advance(_RandomAccessIterator& __i, _Distance __n,
151 random_access_iterator_tag)
154 __glibcxx_function_requires(_RandomAccessIteratorConcept<
155 _RandomAccessIterator>)
171 template<typename _InputIterator, typename _Distance>
176 typename iterator_traits<_InputIterator>::difference_type __d = __n;
180 #if __cplusplus >= 201103L
182 template<
typename _ForwardIterator>
183 inline _ForwardIterator
184 next(_ForwardIterator __x,
typename
185 iterator_traits<_ForwardIterator>::difference_type __n = 1)
191 template<
typename _B
idirectionalIterator>
192 inline _BidirectionalIterator
193 prev(_BidirectionalIterator __x,
typename
194 iterator_traits<_BidirectionalIterator>::difference_type __n = 1)
202 _GLIBCXX_END_NAMESPACE_VERSION
iterator_traits< _InputIterator >::difference_type distance(_InputIterator __first, _InputIterator __last)
A generalization of pointer arithmetic.
void advance(_InputIterator &__i, _Distance __n)
A generalization of pointer arithmetic.
iterator_traits< _Iter >::iterator_category __iterator_category(const _Iter &)