60 #ifndef _STL_ITERATOR_H 61 #define _STL_ITERATOR_H 1 68 namespace std _GLIBCXX_VISIBILITY(default)
70 _GLIBCXX_BEGIN_NAMESPACE_VERSION
96 template<
typename _Iterator>
98 :
public iterator<typename iterator_traits<_Iterator>::iterator_category,
99 typename iterator_traits<_Iterator>::value_type,
100 typename iterator_traits<_Iterator>::difference_type,
101 typename iterator_traits<_Iterator>::pointer,
102 typename iterator_traits<_Iterator>::reference>
107 typedef iterator_traits<_Iterator> __traits_type;
110 typedef _Iterator iterator_type;
111 typedef typename __traits_type::difference_type difference_type;
112 typedef typename __traits_type::pointer pointer;
113 typedef typename __traits_type::reference reference;
133 : current(__x.current) { }
139 template<
typename _Iter>
141 : current(__x.
base()) { }
163 _Iterator __tmp = current;
277 {
return *(*
this + __n); }
290 template<
typename _Iterator>
294 {
return __x.
base() == __y.
base(); }
296 template<
typename _Iterator>
298 operator<(const reverse_iterator<_Iterator>& __x,
300 {
return __y.
base() < __x.base(); }
302 template<
typename _Iterator>
306 {
return !(__x == __y); }
308 template<
typename _Iterator>
312 {
return __y < __x; }
314 template<
typename _Iterator>
316 operator<=(const reverse_iterator<_Iterator>& __x,
318 {
return !(__y < __x); }
320 template<
typename _Iterator>
324 {
return !(__x < __y); }
326 template<
typename _Iterator>
327 #if __cplusplus < 201103L 328 inline typename reverse_iterator<_Iterator>::difference_type
335 -> decltype(__x.
base() - __y.
base())
339 template<
typename _Iterator>
341 operator+(
typename reverse_iterator<_Iterator>::difference_type __n,
347 template<
typename _IteratorL,
typename _IteratorR>
351 {
return __x.
base() == __y.
base(); }
353 template<
typename _IteratorL,
typename _IteratorR>
355 operator<(const reverse_iterator<_IteratorL>& __x,
357 {
return __y.
base() < __x.base(); }
359 template<
typename _IteratorL,
typename _IteratorR>
363 {
return !(__x == __y); }
365 template<
typename _IteratorL,
typename _IteratorR>
369 {
return __y < __x; }
371 template<
typename _IteratorL,
typename _IteratorR>
373 operator<=(const reverse_iterator<_IteratorL>& __x,
375 {
return !(__y < __x); }
377 template<
typename _IteratorL,
typename _IteratorR>
381 {
return !(__x < __y); }
383 template<
typename _IteratorL,
typename _IteratorR>
384 #if __cplusplus >= 201103L 389 -> decltype(__y.
base() - __x.
base())
391 inline typename reverse_iterator<_IteratorL>::difference_type
398 #if __cplusplus >= 201103L 400 template<
typename _Iterator>
402 __make_reverse_iterator(_Iterator __i)
405 # if __cplusplus > 201103L 406 # define __cpp_lib_make_reverse_iterator 201402 411 template<
typename _Iterator>
418 #if __cplusplus >= 201103L 419 template<
typename _Iterator>
422 -> decltype(__make_reverse_iterator(__niter_base(__it.
base())))
423 {
return __make_reverse_iterator(__niter_base(__it.
base())); }
425 template<
typename _Iterator>
426 struct __is_move_iterator<reverse_iterator<_Iterator> >
427 : __is_move_iterator<_Iterator>
430 template<
typename _Iterator>
433 -> decltype(__make_reverse_iterator(__miter_base(__it.
base())))
434 {
return __make_reverse_iterator(__miter_base(__it.
base())); }
448 template<
typename _Container>
450 :
public iterator<output_iterator_tag, void, void, void, void>
453 _Container* container;
475 #if __cplusplus < 201103L 477 operator=(
typename _Container::const_reference __value)
479 container->push_back(__value);
484 operator=(
const typename _Container::value_type& __value)
486 container->push_back(__value);
491 operator=(
typename _Container::value_type&& __value)
493 container->push_back(std::move(__value));
525 template<
typename _Container>
540 template<
typename _Container>
542 :
public iterator<output_iterator_tag, void, void, void, void>
545 _Container* container;
566 #if __cplusplus < 201103L 568 operator=(
typename _Container::const_reference __value)
570 container->push_front(__value);
575 operator=(
const typename _Container::value_type& __value)
577 container->push_front(__value);
582 operator=(
typename _Container::value_type&& __value)
584 container->push_front(std::move(__value));
616 template<
typename _Container>
635 template<
typename _Container>
637 :
public iterator<output_iterator_tag, void, void, void, void>
640 _Container* container;
641 typename _Container::iterator iter;
677 #if __cplusplus < 201103L 679 operator=(
typename _Container::const_reference __value)
681 iter = container->insert(iter, __value);
687 operator=(
const typename _Container::value_type& __value)
689 iter = container->insert(iter, __value);
695 operator=(
typename _Container::value_type&& __value)
697 iter = container->insert(iter, std::move(__value));
730 template<
typename _Container,
typename _Iterator>
735 typename _Container::iterator(__i));
740 _GLIBCXX_END_NAMESPACE_VERSION
743 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
745 _GLIBCXX_BEGIN_NAMESPACE_VERSION
754 using std::iterator_traits;
756 template<
typename _Iterator,
typename _Container>
757 class __normal_iterator
760 _Iterator _M_current;
762 typedef iterator_traits<_Iterator> __traits_type;
765 typedef _Iterator iterator_type;
767 typedef typename __traits_type::value_type
value_type;
768 typedef typename __traits_type::difference_type difference_type;
769 typedef typename __traits_type::reference reference;
770 typedef typename __traits_type::pointer pointer;
772 _GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT
773 : _M_current(_Iterator()) { }
776 __normal_iterator(
const _Iterator& __i) _GLIBCXX_NOEXCEPT
777 : _M_current(__i) { }
780 template<
typename _Iter>
781 __normal_iterator(
const __normal_iterator<_Iter,
782 typename __enable_if<
783 (std::__are_same<_Iter, typename _Container::pointer>::__value),
784 _Container>::__type>& __i) _GLIBCXX_NOEXCEPT
785 : _M_current(__i.base()) { }
790 {
return *_M_current; }
794 {
return _M_current; }
805 {
return __normal_iterator(_M_current++); }
817 {
return __normal_iterator(_M_current--); }
821 operator[](difference_type __n)
const _GLIBCXX_NOEXCEPT
822 {
return _M_current[__n]; }
825 operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
826 { _M_current += __n;
return *
this; }
829 operator+(difference_type __n)
const _GLIBCXX_NOEXCEPT
830 {
return __normal_iterator(_M_current + __n); }
833 operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
834 { _M_current -= __n;
return *
this; }
837 operator-(difference_type __n)
const _GLIBCXX_NOEXCEPT
838 {
return __normal_iterator(_M_current - __n); }
841 base()
const _GLIBCXX_NOEXCEPT
842 {
return _M_current; }
854 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
856 operator==(
const __normal_iterator<_IteratorL, _Container>& __lhs,
857 const __normal_iterator<_IteratorR, _Container>& __rhs)
859 {
return __lhs.base() == __rhs.base(); }
861 template<
typename _Iterator,
typename _Container>
863 operator==(
const __normal_iterator<_Iterator, _Container>& __lhs,
864 const __normal_iterator<_Iterator, _Container>& __rhs)
866 {
return __lhs.base() == __rhs.base(); }
868 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
870 operator!=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
871 const __normal_iterator<_IteratorR, _Container>& __rhs)
873 {
return __lhs.base() != __rhs.base(); }
875 template<
typename _Iterator,
typename _Container>
877 operator!=(
const __normal_iterator<_Iterator, _Container>& __lhs,
878 const __normal_iterator<_Iterator, _Container>& __rhs)
880 {
return __lhs.base() != __rhs.base(); }
883 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
885 operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
886 const __normal_iterator<_IteratorR, _Container>& __rhs)
888 {
return __lhs.base() < __rhs.base(); }
890 template<
typename _Iterator,
typename _Container>
892 operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
893 const __normal_iterator<_Iterator, _Container>& __rhs)
895 {
return __lhs.base() < __rhs.base(); }
897 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
899 operator>(
const __normal_iterator<_IteratorL, _Container>& __lhs,
900 const __normal_iterator<_IteratorR, _Container>& __rhs)
902 {
return __lhs.base() > __rhs.base(); }
904 template<
typename _Iterator,
typename _Container>
906 operator>(
const __normal_iterator<_Iterator, _Container>& __lhs,
907 const __normal_iterator<_Iterator, _Container>& __rhs)
909 {
return __lhs.base() > __rhs.base(); }
911 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
913 operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
914 const __normal_iterator<_IteratorR, _Container>& __rhs)
916 {
return __lhs.base() <= __rhs.base(); }
918 template<
typename _Iterator,
typename _Container>
920 operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
921 const __normal_iterator<_Iterator, _Container>& __rhs)
923 {
return __lhs.base() <= __rhs.base(); }
925 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
927 operator>=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
928 const __normal_iterator<_IteratorR, _Container>& __rhs)
930 {
return __lhs.base() >= __rhs.base(); }
932 template<
typename _Iterator,
typename _Container>
934 operator>=(
const __normal_iterator<_Iterator, _Container>& __lhs,
935 const __normal_iterator<_Iterator, _Container>& __rhs)
937 {
return __lhs.base() >= __rhs.base(); }
943 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
944 #if __cplusplus >= 201103L 947 operator-(
const __normal_iterator<_IteratorL, _Container>& __lhs,
948 const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept
949 -> decltype(__lhs.base() - __rhs.base())
951 inline typename __normal_iterator<_IteratorL, _Container>::difference_type
952 operator-(
const __normal_iterator<_IteratorL, _Container>& __lhs,
953 const __normal_iterator<_IteratorR, _Container>& __rhs)
955 {
return __lhs.base() - __rhs.base(); }
957 template<
typename _Iterator,
typename _Container>
958 inline typename __normal_iterator<_Iterator, _Container>::difference_type
959 operator-(
const __normal_iterator<_Iterator, _Container>& __lhs,
960 const __normal_iterator<_Iterator, _Container>& __rhs)
962 {
return __lhs.base() - __rhs.base(); }
964 template<
typename _Iterator,
typename _Container>
965 inline __normal_iterator<_Iterator, _Container>
966 operator+(
typename __normal_iterator<_Iterator, _Container>::difference_type
967 __n,
const __normal_iterator<_Iterator, _Container>& __i)
969 {
return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
971 _GLIBCXX_END_NAMESPACE_VERSION
974 namespace std _GLIBCXX_VISIBILITY(default)
976 _GLIBCXX_BEGIN_NAMESPACE_VERSION
978 template<
typename _Iterator,
typename _Container>
980 __niter_base(__gnu_cxx::__normal_iterator<_Iterator, _Container> __it)
981 {
return __it.base(); }
983 _GLIBCXX_END_NAMESPACE_VERSION
986 #if __cplusplus >= 201103L 988 namespace std _GLIBCXX_VISIBILITY(default)
990 _GLIBCXX_BEGIN_NAMESPACE_VERSION
1006 template<
typename _Iterator>
1010 _Iterator _M_current;
1012 typedef iterator_traits<_Iterator> __traits_type;
1013 typedef typename __traits_type::reference __base_ref;
1016 typedef _Iterator iterator_type;
1018 typedef typename __traits_type::value_type
value_type;
1019 typedef typename __traits_type::difference_type difference_type;
1021 typedef _Iterator pointer;
1024 typedef typename conditional<is_reference<__base_ref>::value,
1025 typename remove_reference<__base_ref>::type&&,
1026 __base_ref>::type reference;
1033 : _M_current(__i) { }
1035 template<
typename _Iter>
1037 : _M_current(__i.base()) { }
1041 {
return _M_current; }
1045 {
return static_cast<reference
>(*_M_current); }
1049 {
return _M_current; }
1105 {
return std::move(_M_current[__n]); }
1111 template<
typename _IteratorL,
typename _IteratorR>
1115 {
return __x.base() == __y.base(); }
1117 template<
typename _Iterator>
1121 {
return __x.base() == __y.base(); }
1123 template<
typename _IteratorL,
typename _IteratorR>
1127 {
return !(__x == __y); }
1129 template<
typename _Iterator>
1133 {
return !(__x == __y); }
1135 template<
typename _IteratorL,
typename _IteratorR>
1137 operator<(const move_iterator<_IteratorL>& __x,
1139 {
return __x.base() < __y.base(); }
1141 template<
typename _Iterator>
1143 operator<(const move_iterator<_Iterator>& __x,
1145 {
return __x.base() < __y.base(); }
1147 template<
typename _IteratorL,
typename _IteratorR>
1149 operator<=(const move_iterator<_IteratorL>& __x,
1151 {
return !(__y < __x); }
1153 template<
typename _Iterator>
1155 operator<=(const move_iterator<_Iterator>& __x,
1157 {
return !(__y < __x); }
1159 template<
typename _IteratorL,
typename _IteratorR>
1163 {
return __y < __x; }
1165 template<
typename _Iterator>
1169 {
return __y < __x; }
1171 template<
typename _IteratorL,
typename _IteratorR>
1175 {
return !(__x < __y); }
1177 template<
typename _Iterator>
1181 {
return !(__x < __y); }
1184 template<
typename _IteratorL,
typename _IteratorR>
1188 -> decltype(__x.base() - __y.base())
1189 {
return __x.base() - __y.base(); }
1191 template<
typename _Iterator>
1195 -> decltype(__x.base() - __y.base())
1196 {
return __x.base() - __y.base(); }
1198 template<
typename _Iterator>
1200 operator+(
typename move_iterator<_Iterator>::difference_type __n,
1202 {
return __x + __n; }
1204 template<
typename _Iterator>
1206 make_move_iterator(_Iterator __i)
1209 template<
typename _Iterator,
typename _ReturnType
1210 =
typename conditional<__move_if_noexcept_cond
1211 <
typename iterator_traits<_Iterator>::value_type>::value,
1214 __make_move_if_noexcept_iterator(_Iterator __i)
1215 {
return _ReturnType(__i); }
1219 template<
typename _Tp,
typename _ReturnType
1220 =
typename conditional<__move_if_noexcept_cond<_Tp>::value,
1223 __make_move_if_noexcept_iterator(_Tp* __i)
1224 {
return _ReturnType(__i); }
1228 template<
typename _Iterator>
1231 -> decltype(make_move_iterator(__niter_base(__it.base())))
1232 {
return make_move_iterator(__niter_base(__it.base())); }
1234 template<
typename _Iterator>
1235 struct __is_move_iterator<move_iterator<_Iterator> >
1237 enum { __value = 1 };
1238 typedef __true_type __type;
1241 template<
typename _Iterator>
1244 -> decltype(__miter_base(__it.base()))
1245 {
return __miter_base(__it.base()); }
1247 _GLIBCXX_END_NAMESPACE_VERSION
1250 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter) 1251 #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \ 1252 std::__make_move_if_noexcept_iterator(_Iter) 1254 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter) 1255 #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter) 1258 #ifdef _GLIBCXX_DEBUG back_insert_iterator & operator++()
Simply returns *this. (This iterator does not move.)
front_insert_iterator operator++(int)
Simply returns *this. (This iterator does not move.)
_Container container_type
A nested typedef for the type of whatever container you used.
front_insert_iterator(_Container &__x)
The only way to create this iterator is with a container.
reverse_iterator< _Iterator > make_reverse_iterator(_Iterator __i)
Generator function for reverse_iterator.
back_insert_iterator(_Container &__x)
The only way to create this iterator is with a container.
reverse_iterator(const reverse_iterator< _Iter > &__x)
reverse_iterator & operator+=(difference_type __n)
reverse_iterator operator++(int)
GNU extensions for public use.
reverse_iterator(iterator_type __x)
reverse_iterator operator+(difference_type __n) const
iterator_traits< _Iterator >::iterator_category iterator_category
One of the tag types.
_Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
reverse_iterator & operator-=(difference_type __n)
reference operator*() const
back_insert_iterator & operator*()
Simply returns *this.
insert_iterator(_Container &__x, typename _Container::iterator __i)
insert_iterator & operator++()
Simply returns *this. (This iterator does not move.)
front_insert_iterator & operator++()
Simply returns *this. (This iterator does not move.)
front_insert_iterator & operator=(const typename _Container::value_type &__value)
insert_iterator & operator=(const typename _Container::value_type &__value)
back_insert_iterator< _Container > back_inserter(_Container &__x)
front_insert_iterator & operator*()
Simply returns *this.
insert_iterator< _Container > inserter(_Container &__x, _Iterator __i)
reverse_iterator(const reverse_iterator &__x)
Turns assignment into insertion.
front_insert_iterator< _Container > front_inserter(_Container &__x)
reverse_iterator & operator--()
pointer operator->() const
iterator_traits< _Iterator >::value_type value_type
The type "pointed to" by the iterator.
_Container container_type
A nested typedef for the type of whatever container you used.
back_insert_iterator & operator=(const typename _Container::value_type &__value)
Turns assignment into insertion.
ISO C++ entities toplevel namespace is std.
reverse_iterator & operator++()
reference operator[](difference_type __n) const
back_insert_iterator operator++(int)
Simply returns *this. (This iterator does not move.)
insert_iterator & operator*()
Simply returns *this.
iterator_type base() const
insert_iterator & operator++(int)
Simply returns *this. (This iterator does not move.)
_Container container_type
A nested typedef for the type of whatever container you used.
reverse_iterator operator--(int)
reverse_iterator operator-(difference_type __n) const
Turns assignment into insertion.