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 inline typename reverse_iterator<_Iterator>::difference_type
332 template<
typename _Iterator>
334 operator+(
typename reverse_iterator<_Iterator>::difference_type __n,
340 template<
typename _IteratorL,
typename _IteratorR>
344 {
return __x.
base() == __y.
base(); }
346 template<
typename _IteratorL,
typename _IteratorR>
348 operator<(const reverse_iterator<_IteratorL>& __x,
350 {
return __y.
base() < __x.base(); }
352 template<
typename _IteratorL,
typename _IteratorR>
356 {
return !(__x == __y); }
358 template<
typename _IteratorL,
typename _IteratorR>
362 {
return __y < __x; }
364 template<
typename _IteratorL,
typename _IteratorR>
366 operator<=(const reverse_iterator<_IteratorL>& __x,
368 {
return !(__y < __x); }
370 template<
typename _IteratorL,
typename _IteratorR>
374 {
return !(__x < __y); }
376 template<
typename _IteratorL,
typename _IteratorR>
377 #if __cplusplus >= 201103L 382 -> decltype(__y.
base() - __x.
base())
384 inline typename reverse_iterator<_IteratorL>::difference_type
391 #if __cplusplus > 201103L 392 #define __cpp_lib_make_reverse_iterator 201402 397 template<
typename _Iterator>
414 template<
typename _Container>
416 :
public iterator<output_iterator_tag, void, void, void, void>
419 _Container* container;
440 #if __cplusplus < 201103L 442 operator=(
typename _Container::const_reference __value)
444 container->push_back(__value);
449 operator=(
const typename _Container::value_type& __value)
451 container->push_back(__value);
456 operator=(
typename _Container::value_type&& __value)
458 container->push_back(std::move(__value));
490 template<
typename _Container>
505 template<
typename _Container>
507 :
public iterator<output_iterator_tag, void, void, void, void>
510 _Container* container;
530 #if __cplusplus < 201103L 532 operator=(
typename _Container::const_reference __value)
534 container->push_front(__value);
539 operator=(
const typename _Container::value_type& __value)
541 container->push_front(__value);
546 operator=(
typename _Container::value_type&& __value)
548 container->push_front(std::move(__value));
580 template<
typename _Container>
599 template<
typename _Container>
601 :
public iterator<output_iterator_tag, void, void, void, void>
604 _Container* container;
605 typename _Container::iterator iter;
616 : container(&__x), iter(__i) {}
641 #if __cplusplus < 201103L 643 operator=(
typename _Container::const_reference __value)
645 iter = container->insert(iter, __value);
651 operator=(
const typename _Container::value_type& __value)
653 iter = container->insert(iter, __value);
659 operator=(
typename _Container::value_type&& __value)
661 iter = container->insert(iter, std::move(__value));
694 template<
typename _Container,
typename _Iterator>
699 typename _Container::iterator(__i));
704 _GLIBCXX_END_NAMESPACE_VERSION
707 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
709 _GLIBCXX_BEGIN_NAMESPACE_VERSION
718 using std::iterator_traits;
720 template<
typename _Iterator,
typename _Container>
721 class __normal_iterator
724 _Iterator _M_current;
726 typedef iterator_traits<_Iterator> __traits_type;
729 typedef _Iterator iterator_type;
731 typedef typename __traits_type::value_type
value_type;
732 typedef typename __traits_type::difference_type difference_type;
733 typedef typename __traits_type::reference reference;
734 typedef typename __traits_type::pointer pointer;
736 _GLIBCXX_CONSTEXPR __normal_iterator() _GLIBCXX_NOEXCEPT
737 : _M_current(_Iterator()) { }
740 __normal_iterator(
const _Iterator& __i) _GLIBCXX_NOEXCEPT
741 : _M_current(__i) { }
744 template<
typename _Iter>
745 __normal_iterator(
const __normal_iterator<_Iter,
746 typename __enable_if<
747 (std::__are_same<_Iter, typename _Container::pointer>::__value),
748 _Container>::__type>& __i) _GLIBCXX_NOEXCEPT
749 : _M_current(__i.base()) { }
754 {
return *_M_current; }
758 {
return _M_current; }
769 {
return __normal_iterator(_M_current++); }
781 {
return __normal_iterator(_M_current--); }
785 operator[](difference_type __n)
const _GLIBCXX_NOEXCEPT
786 {
return _M_current[__n]; }
789 operator+=(difference_type __n) _GLIBCXX_NOEXCEPT
790 { _M_current += __n;
return *
this; }
793 operator+(difference_type __n)
const _GLIBCXX_NOEXCEPT
794 {
return __normal_iterator(_M_current + __n); }
797 operator-=(difference_type __n) _GLIBCXX_NOEXCEPT
798 { _M_current -= __n;
return *
this; }
801 operator-(difference_type __n)
const _GLIBCXX_NOEXCEPT
802 {
return __normal_iterator(_M_current - __n); }
805 base()
const _GLIBCXX_NOEXCEPT
806 {
return _M_current; }
818 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
820 operator==(
const __normal_iterator<_IteratorL, _Container>& __lhs,
821 const __normal_iterator<_IteratorR, _Container>& __rhs)
823 {
return __lhs.base() == __rhs.base(); }
825 template<
typename _Iterator,
typename _Container>
827 operator==(
const __normal_iterator<_Iterator, _Container>& __lhs,
828 const __normal_iterator<_Iterator, _Container>& __rhs)
830 {
return __lhs.base() == __rhs.base(); }
832 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
834 operator!=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
835 const __normal_iterator<_IteratorR, _Container>& __rhs)
837 {
return __lhs.base() != __rhs.base(); }
839 template<
typename _Iterator,
typename _Container>
841 operator!=(
const __normal_iterator<_Iterator, _Container>& __lhs,
842 const __normal_iterator<_Iterator, _Container>& __rhs)
844 {
return __lhs.base() != __rhs.base(); }
847 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
849 operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
850 const __normal_iterator<_IteratorR, _Container>& __rhs)
852 {
return __lhs.base() < __rhs.base(); }
854 template<
typename _Iterator,
typename _Container>
856 operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
857 const __normal_iterator<_Iterator, _Container>& __rhs)
859 {
return __lhs.base() < __rhs.base(); }
861 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
863 operator>(
const __normal_iterator<_IteratorL, _Container>& __lhs,
864 const __normal_iterator<_IteratorR, _Container>& __rhs)
866 {
return __lhs.base() > __rhs.base(); }
868 template<
typename _Iterator,
typename _Container>
870 operator>(
const __normal_iterator<_Iterator, _Container>& __lhs,
871 const __normal_iterator<_Iterator, _Container>& __rhs)
873 {
return __lhs.base() > __rhs.base(); }
875 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
877 operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
878 const __normal_iterator<_IteratorR, _Container>& __rhs)
880 {
return __lhs.base() <= __rhs.base(); }
882 template<
typename _Iterator,
typename _Container>
884 operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
885 const __normal_iterator<_Iterator, _Container>& __rhs)
887 {
return __lhs.base() <= __rhs.base(); }
889 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
891 operator>=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
892 const __normal_iterator<_IteratorR, _Container>& __rhs)
894 {
return __lhs.base() >= __rhs.base(); }
896 template<
typename _Iterator,
typename _Container>
898 operator>=(
const __normal_iterator<_Iterator, _Container>& __lhs,
899 const __normal_iterator<_Iterator, _Container>& __rhs)
901 {
return __lhs.base() >= __rhs.base(); }
907 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
908 #if __cplusplus >= 201103L 911 operator-(
const __normal_iterator<_IteratorL, _Container>& __lhs,
912 const __normal_iterator<_IteratorR, _Container>& __rhs) noexcept
913 -> decltype(__lhs.base() - __rhs.base())
915 inline typename __normal_iterator<_IteratorL, _Container>::difference_type
916 operator-(
const __normal_iterator<_IteratorL, _Container>& __lhs,
917 const __normal_iterator<_IteratorR, _Container>& __rhs)
919 {
return __lhs.base() - __rhs.base(); }
921 template<
typename _Iterator,
typename _Container>
922 inline typename __normal_iterator<_Iterator, _Container>::difference_type
923 operator-(
const __normal_iterator<_Iterator, _Container>& __lhs,
924 const __normal_iterator<_Iterator, _Container>& __rhs)
926 {
return __lhs.base() - __rhs.base(); }
928 template<
typename _Iterator,
typename _Container>
929 inline __normal_iterator<_Iterator, _Container>
930 operator+(
typename __normal_iterator<_Iterator, _Container>::difference_type
931 __n,
const __normal_iterator<_Iterator, _Container>& __i)
933 {
return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
935 _GLIBCXX_END_NAMESPACE_VERSION
938 #if __cplusplus >= 201103L 940 namespace std _GLIBCXX_VISIBILITY(default)
942 _GLIBCXX_BEGIN_NAMESPACE_VERSION
958 template<
typename _Iterator>
962 _Iterator _M_current;
964 typedef iterator_traits<_Iterator> __traits_type;
965 typedef typename __traits_type::reference __base_ref;
968 typedef _Iterator iterator_type;
970 typedef typename __traits_type::value_type
value_type;
971 typedef typename __traits_type::difference_type difference_type;
973 typedef _Iterator pointer;
976 typedef typename conditional<is_reference<__base_ref>::value,
977 typename remove_reference<__base_ref>::type&&,
978 __base_ref>::type reference;
985 : _M_current(__i) { }
987 template<
typename _Iter>
989 : _M_current(__i.base()) { }
993 {
return _M_current; }
997 {
return static_cast<reference
>(*_M_current); }
1001 {
return _M_current; }
1057 {
return std::move(_M_current[__n]); }
1063 template<
typename _IteratorL,
typename _IteratorR>
1067 {
return __x.base() == __y.base(); }
1069 template<
typename _Iterator>
1073 {
return __x.base() == __y.base(); }
1075 template<
typename _IteratorL,
typename _IteratorR>
1079 {
return !(__x == __y); }
1081 template<
typename _Iterator>
1085 {
return !(__x == __y); }
1087 template<
typename _IteratorL,
typename _IteratorR>
1089 operator<(const move_iterator<_IteratorL>& __x,
1091 {
return __x.base() < __y.base(); }
1093 template<
typename _Iterator>
1095 operator<(const move_iterator<_Iterator>& __x,
1097 {
return __x.base() < __y.base(); }
1099 template<
typename _IteratorL,
typename _IteratorR>
1101 operator<=(const move_iterator<_IteratorL>& __x,
1103 {
return !(__y < __x); }
1105 template<
typename _Iterator>
1107 operator<=(const move_iterator<_Iterator>& __x,
1109 {
return !(__y < __x); }
1111 template<
typename _IteratorL,
typename _IteratorR>
1115 {
return __y < __x; }
1117 template<
typename _Iterator>
1121 {
return __y < __x; }
1123 template<
typename _IteratorL,
typename _IteratorR>
1127 {
return !(__x < __y); }
1129 template<
typename _Iterator>
1133 {
return !(__x < __y); }
1136 template<
typename _IteratorL,
typename _IteratorR>
1140 -> decltype(__x.base() - __y.base())
1141 {
return __x.base() - __y.base(); }
1143 template<
typename _Iterator>
1147 -> decltype(__x.base() - __y.base())
1148 {
return __x.base() - __y.base(); }
1150 template<
typename _Iterator>
1152 operator+(
typename move_iterator<_Iterator>::difference_type __n,
1154 {
return __x + __n; }
1156 template<
typename _Iterator>
1158 make_move_iterator(_Iterator __i)
1161 template<
typename _Iterator,
typename _ReturnType
1162 =
typename conditional<__move_if_noexcept_cond
1163 <
typename iterator_traits<_Iterator>::value_type>::value,
1166 __make_move_if_noexcept_iterator(_Iterator __i)
1167 {
return _ReturnType(__i); }
1171 _GLIBCXX_END_NAMESPACE_VERSION
1174 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter) 1175 #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) \ 1176 std::__make_move_if_noexcept_iterator(_Iter) 1178 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter) 1179 #define _GLIBCXX_MAKE_MOVE_IF_NOEXCEPT_ITERATOR(_Iter) (_Iter) insert_iterator< _Container > inserter(_Container &__x, _Iterator __i)
iterator_traits< _Iterator >::value_type value_type
The type "pointed to" by the iterator.
reverse_iterator(const reverse_iterator< _Iter > &__x)
back_insert_iterator(_Container &__x)
The only way to create this iterator is with a container.
insert_iterator & operator*()
Simply returns *this.
front_insert_iterator< _Container > front_inserter(_Container &__x)
back_insert_iterator< _Container > back_inserter(_Container &__x)
reverse_iterator operator--(int)
iterator_type base() const
Turns assignment into insertion.
insert_iterator & operator++(int)
Simply returns *this. (This iterator does not move.)
back_insert_iterator operator++(int)
Simply returns *this. (This iterator does not move.)
GNU extensions for public use.
reverse_iterator operator-(difference_type __n) const
back_insert_iterator & operator*()
Simply returns *this.
reverse_iterator & operator--()
reverse_iterator operator++(int)
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.
reverse_iterator(const reverse_iterator &__x)
_Container container_type
A nested typedef for the type of whatever container you used.
front_insert_iterator & operator=(const typename _Container::value_type &__value)
reverse_iterator & operator+=(difference_type __n)
reverse_iterator operator+(difference_type __n) const
pointer operator->() const
reverse_iterator(iterator_type __x)
back_insert_iterator & operator=(const typename _Container::value_type &__value)
insert_iterator(_Container &__x, typename _Container::iterator __i)
reverse_iterator & operator-=(difference_type __n)
front_insert_iterator(_Container &__x)
The only way to create this iterator is with a container.
back_insert_iterator & operator++()
Simply returns *this. (This iterator does not move.)
reverse_iterator & operator++()
_Container container_type
A nested typedef for the type of whatever container you used.
front_insert_iterator & operator++()
Simply returns *this. (This iterator does not move.)
Turns assignment into insertion.
insert_iterator & operator++()
Simply returns *this. (This iterator does not move.)
reference operator*() const
reverse_iterator< _Iterator > make_reverse_iterator(_Iterator __i)
Generator function for reverse_iterator.
front_insert_iterator & operator*()
Simply returns *this.
insert_iterator & operator=(const typename _Container::value_type &__value)
Turns assignment into insertion.
ISO C++ entities toplevel namespace is std.
iterator_traits< _Iterator >::iterator_category iterator_category
One of the tag types.
reference operator[](difference_type __n) const