59#ifndef _STL_ITERATOR_BASE_FUNCS_H
60#define _STL_ITERATOR_BASE_FUNCS_H 1
62#pragma GCC system_header
67namespace std _GLIBCXX_VISIBILITY(default)
69_GLIBCXX_BEGIN_NAMESPACE_VERSION
71_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
73 template <
typename>
struct _List_iterator;
74 template <
typename>
struct _List_const_iterator;
75_GLIBCXX_END_NAMESPACE_CONTAINER
77 template<
typename _InputIterator>
78 inline _GLIBCXX14_CONSTEXPR
79 typename iterator_traits<_InputIterator>::difference_type
80 __distance(_InputIterator __first, _InputIterator __last,
84 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
86 typename iterator_traits<_InputIterator>::difference_type __n = 0;
87 while (__first != __last)
95 template<
typename _RandomAccessIterator>
96 inline _GLIBCXX14_CONSTEXPR
97 typename iterator_traits<_RandomAccessIterator>::difference_type
98 __distance(_RandomAccessIterator __first, _RandomAccessIterator __last,
99 random_access_iterator_tag)
102 __glibcxx_function_requires(_RandomAccessIteratorConcept<
103 _RandomAccessIterator>)
104 return __last - __first;
107#if _GLIBCXX_USE_CXX11_ABI
109 template<
typename _Tp>
111 __distance(_GLIBCXX_STD_C::_List_iterator<_Tp>,
112 _GLIBCXX_STD_C::_List_iterator<_Tp>,
115 template<
typename _Tp>
117 __distance(_GLIBCXX_STD_C::_List_const_iterator<_Tp>,
118 _GLIBCXX_STD_C::_List_const_iterator<_Tp>,
135 template<
typename _InputIterator>
136 inline _GLIBCXX17_CONSTEXPR
137 typename iterator_traits<_InputIterator>::difference_type
138 distance(_InputIterator __first, _InputIterator __last)
141 return std::__distance(__first, __last,
145 template<
typename _InputIterator,
typename _Distance>
146 inline _GLIBCXX14_CONSTEXPR
void
147 __advance(_InputIterator& __i, _Distance __n, input_iterator_tag)
150 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
151 __glibcxx_assert(__n >= 0);
156 template<
typename _B
idirectionalIterator,
typename _Distance>
157 inline _GLIBCXX14_CONSTEXPR
void
158 __advance(_BidirectionalIterator& __i, _Distance __n,
159 bidirectional_iterator_tag)
162 __glibcxx_function_requires(_BidirectionalIteratorConcept<
163 _BidirectionalIterator>)
172 template<typename _RandomAccessIterator, typename _Distance>
173 inline _GLIBCXX14_CONSTEXPR
void
174 __advance(_RandomAccessIterator& __i, _Distance __n,
175 random_access_iterator_tag)
178 __glibcxx_function_requires(_RandomAccessIteratorConcept<
179 _RandomAccessIterator>)
180 if (__builtin_constant_p(__n) && __n == 1)
182 else if (__builtin_constant_p(__n) && __n == -1)
200 template<typename _InputIterator, typename _Distance>
201 inline _GLIBCXX17_CONSTEXPR
void
209#if __cplusplus >= 201103L
211 template<
typename _InputIterator>
212 inline _GLIBCXX17_CONSTEXPR _InputIterator
213 next(_InputIterator __x,
typename
214 iterator_traits<_InputIterator>::difference_type __n = 1)
217 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
222 template<
typename _B
idirectionalIterator>
223 inline _GLIBCXX17_CONSTEXPR _BidirectionalIterator
224 prev(_BidirectionalIterator __x,
typename
225 iterator_traits<_BidirectionalIterator>::difference_type __n = 1)
228 __glibcxx_function_requires(_BidirectionalIteratorConcept<
229 _BidirectionalIterator>)
236_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.