61 #ifndef _STL_ITERATOR_H
62 #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()) { }
158 _Iterator __tmp = current;
270 {
return *(*
this + __n); }
283 template<
typename _Iterator>
287 {
return __x.
base() == __y.
base(); }
289 template<
typename _Iterator>
291 operator<(const reverse_iterator<_Iterator>& __x,
292 const reverse_iterator<_Iterator>& __y)
293 {
return __y.base() < __x.base(); }
295 template<
typename _Iterator>
297 operator!=(
const reverse_iterator<_Iterator>& __x,
298 const reverse_iterator<_Iterator>& __y)
299 {
return !(__x == __y); }
301 template<
typename _Iterator>
303 operator>(
const reverse_iterator<_Iterator>& __x,
304 const reverse_iterator<_Iterator>& __y)
305 {
return __y < __x; }
307 template<
typename _Iterator>
309 operator<=(const reverse_iterator<_Iterator>& __x,
310 const reverse_iterator<_Iterator>& __y)
311 {
return !(__y < __x); }
313 template<
typename _Iterator>
315 operator>=(
const reverse_iterator<_Iterator>& __x,
316 const reverse_iterator<_Iterator>& __y)
317 {
return !(__x < __y); }
319 template<
typename _Iterator>
320 inline typename reverse_iterator<_Iterator>::difference_type
321 operator-(
const reverse_iterator<_Iterator>& __x,
322 const reverse_iterator<_Iterator>& __y)
323 {
return __y.base() - __x.base(); }
325 template<
typename _Iterator>
326 inline reverse_iterator<_Iterator>
327 operator+(
typename reverse_iterator<_Iterator>::difference_type __n,
328 const reverse_iterator<_Iterator>& __x)
329 {
return reverse_iterator<_Iterator>(__x.base() - __n); }
333 template<
typename _IteratorL,
typename _IteratorR>
335 operator==(
const reverse_iterator<_IteratorL>& __x,
336 const reverse_iterator<_IteratorR>& __y)
337 {
return __x.base() == __y.base(); }
339 template<
typename _IteratorL,
typename _IteratorR>
341 operator<(const reverse_iterator<_IteratorL>& __x,
342 const reverse_iterator<_IteratorR>& __y)
343 {
return __y.base() < __x.base(); }
345 template<
typename _IteratorL,
typename _IteratorR>
347 operator!=(
const reverse_iterator<_IteratorL>& __x,
348 const reverse_iterator<_IteratorR>& __y)
349 {
return !(__x == __y); }
351 template<
typename _IteratorL,
typename _IteratorR>
353 operator>(
const reverse_iterator<_IteratorL>& __x,
354 const reverse_iterator<_IteratorR>& __y)
355 {
return __y < __x; }
357 template<
typename _IteratorL,
typename _IteratorR>
359 operator<=(const reverse_iterator<_IteratorL>& __x,
360 const reverse_iterator<_IteratorR>& __y)
361 {
return !(__y < __x); }
363 template<
typename _IteratorL,
typename _IteratorR>
365 operator>=(
const reverse_iterator<_IteratorL>& __x,
366 const reverse_iterator<_IteratorR>& __y)
367 {
return !(__x < __y); }
369 template<
typename _IteratorL,
typename _IteratorR>
370 #ifdef __GXX_EXPERIMENTAL_CXX0X__
373 operator-(
const reverse_iterator<_IteratorL>& __x,
374 const reverse_iterator<_IteratorR>& __y)
375 -> decltype(__y.base() - __x.base())
377 inline typename reverse_iterator<_IteratorL>::difference_type
378 operator-(
const reverse_iterator<_IteratorL>& __x,
379 const reverse_iterator<_IteratorR>& __y)
381 {
return __y.base() - __x.base(); }
395 template<
typename _Container>
397 :
public iterator<output_iterator_tag, void, void, void, void>
400 _Container* container;
421 #ifndef __GXX_EXPERIMENTAL_CXX0X__
423 operator=(
typename _Container::const_reference __value)
425 container->push_back(__value);
430 operator=(
const typename _Container::value_type& __value)
432 container->push_back(__value);
437 operator=(
typename _Container::value_type&& __value)
439 container->push_back(std::move(__value));
471 template<
typename _Container>
472 inline back_insert_iterator<_Container>
486 template<
typename _Container>
488 :
public iterator<output_iterator_tag, void, void, void, void>
491 _Container* container;
511 #ifndef __GXX_EXPERIMENTAL_CXX0X__
513 operator=(
typename _Container::const_reference __value)
515 container->push_front(__value);
520 operator=(
const typename _Container::value_type& __value)
522 container->push_front(__value);
527 operator=(
typename _Container::value_type&& __value)
529 container->push_front(std::move(__value));
561 template<
typename _Container>
562 inline front_insert_iterator<_Container>
580 template<
typename _Container>
582 :
public iterator<output_iterator_tag, void, void, void, void>
585 _Container* container;
586 typename _Container::iterator iter;
597 : container(&__x), iter(__i) {}
622 #ifndef __GXX_EXPERIMENTAL_CXX0X__
624 operator=(
typename _Container::const_reference __value)
626 iter = container->insert(iter, __value);
632 operator=(
const typename _Container::value_type& __value)
634 iter = container->insert(iter, __value);
640 operator=(
typename _Container::value_type&& __value)
642 iter = container->insert(iter, std::move(__value));
675 template<
typename _Container,
typename _Iterator>
676 inline insert_iterator<_Container>
680 typename _Container::iterator(__i));
685 _GLIBCXX_END_NAMESPACE_VERSION
688 namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
690 _GLIBCXX_BEGIN_NAMESPACE_VERSION
699 using std::iterator_traits;
701 template<
typename _Iterator,
typename _Container>
702 class __normal_iterator
705 _Iterator _M_current;
707 typedef iterator_traits<_Iterator> __traits_type;
710 typedef _Iterator iterator_type;
711 typedef typename __traits_type::iterator_category iterator_category;
712 typedef typename __traits_type::value_type value_type;
713 typedef typename __traits_type::difference_type difference_type;
714 typedef typename __traits_type::reference reference;
715 typedef typename __traits_type::pointer pointer;
717 _GLIBCXX_CONSTEXPR __normal_iterator() : _M_current(_Iterator()) { }
720 __normal_iterator(
const _Iterator& __i) : _M_current(__i) { }
723 template<
typename _Iter>
724 __normal_iterator(
const __normal_iterator<_Iter,
725 typename __enable_if<
726 (std::__are_same<_Iter, typename _Container::pointer>::__value),
727 _Container>::__type>& __i)
728 : _M_current(__i.base()) { }
733 {
return *_M_current; }
737 {
return _M_current; }
748 {
return __normal_iterator(_M_current++); }
760 {
return __normal_iterator(_M_current--); }
765 {
return _M_current[__n]; }
768 operator+=(
const difference_type& __n)
769 { _M_current += __n;
return *
this; }
772 operator+(
const difference_type& __n)
const
773 {
return __normal_iterator(_M_current + __n); }
776 operator-=(
const difference_type& __n)
777 { _M_current -= __n;
return *
this; }
780 operator-(
const difference_type& __n)
const
781 {
return __normal_iterator(_M_current - __n); }
785 {
return _M_current; }
797 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
799 operator==(
const __normal_iterator<_IteratorL, _Container>& __lhs,
800 const __normal_iterator<_IteratorR, _Container>& __rhs)
801 {
return __lhs.base() == __rhs.base(); }
803 template<
typename _Iterator,
typename _Container>
805 operator==(
const __normal_iterator<_Iterator, _Container>& __lhs,
806 const __normal_iterator<_Iterator, _Container>& __rhs)
807 {
return __lhs.base() == __rhs.base(); }
809 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
811 operator!=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
812 const __normal_iterator<_IteratorR, _Container>& __rhs)
813 {
return __lhs.base() != __rhs.base(); }
815 template<
typename _Iterator,
typename _Container>
817 operator!=(
const __normal_iterator<_Iterator, _Container>& __lhs,
818 const __normal_iterator<_Iterator, _Container>& __rhs)
819 {
return __lhs.base() != __rhs.base(); }
822 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
824 operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
825 const __normal_iterator<_IteratorR, _Container>& __rhs)
826 {
return __lhs.base() < __rhs.base(); }
828 template<
typename _Iterator,
typename _Container>
830 operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
831 const __normal_iterator<_Iterator, _Container>& __rhs)
832 {
return __lhs.base() < __rhs.base(); }
834 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
836 operator>(
const __normal_iterator<_IteratorL, _Container>& __lhs,
837 const __normal_iterator<_IteratorR, _Container>& __rhs)
838 {
return __lhs.base() > __rhs.base(); }
840 template<
typename _Iterator,
typename _Container>
842 operator>(
const __normal_iterator<_Iterator, _Container>& __lhs,
843 const __normal_iterator<_Iterator, _Container>& __rhs)
844 {
return __lhs.base() > __rhs.base(); }
846 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
848 operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
849 const __normal_iterator<_IteratorR, _Container>& __rhs)
850 {
return __lhs.base() <= __rhs.base(); }
852 template<
typename _Iterator,
typename _Container>
854 operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
855 const __normal_iterator<_Iterator, _Container>& __rhs)
856 {
return __lhs.base() <= __rhs.base(); }
858 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
860 operator>=(
const __normal_iterator<_IteratorL, _Container>& __lhs,
861 const __normal_iterator<_IteratorR, _Container>& __rhs)
862 {
return __lhs.base() >= __rhs.base(); }
864 template<
typename _Iterator,
typename _Container>
866 operator>=(
const __normal_iterator<_Iterator, _Container>& __lhs,
867 const __normal_iterator<_Iterator, _Container>& __rhs)
868 {
return __lhs.base() >= __rhs.base(); }
874 template<
typename _IteratorL,
typename _IteratorR,
typename _Container>
875 #ifdef __GXX_EXPERIMENTAL_CXX0X__
878 operator-(
const __normal_iterator<_IteratorL, _Container>& __lhs,
879 const __normal_iterator<_IteratorR, _Container>& __rhs)
880 -> decltype(__lhs.base() - __rhs.base())
882 inline typename __normal_iterator<_IteratorL, _Container>::difference_type
883 operator-(
const __normal_iterator<_IteratorL, _Container>& __lhs,
884 const __normal_iterator<_IteratorR, _Container>& __rhs)
886 {
return __lhs.base() - __rhs.base(); }
888 template<
typename _Iterator,
typename _Container>
889 inline typename __normal_iterator<_Iterator, _Container>::difference_type
890 operator-(
const __normal_iterator<_Iterator, _Container>& __lhs,
891 const __normal_iterator<_Iterator, _Container>& __rhs)
892 {
return __lhs.base() - __rhs.base(); }
894 template<
typename _Iterator,
typename _Container>
895 inline __normal_iterator<_Iterator, _Container>
896 operator+(
typename __normal_iterator<_Iterator, _Container>::difference_type
897 __n,
const __normal_iterator<_Iterator, _Container>& __i)
898 {
return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
900 _GLIBCXX_END_NAMESPACE_VERSION
903 #ifdef __GXX_EXPERIMENTAL_CXX0X__
905 namespace std _GLIBCXX_VISIBILITY(default)
907 _GLIBCXX_BEGIN_NAMESPACE_VERSION
923 template<
typename _Iterator>
927 _Iterator _M_current;
929 typedef iterator_traits<_Iterator> __traits_type;
932 typedef _Iterator iterator_type;
933 typedef typename __traits_type::iterator_category iterator_category;
934 typedef typename __traits_type::value_type value_type;
935 typedef typename __traits_type::difference_type difference_type;
937 typedef _Iterator pointer;
938 typedef value_type&& reference;
944 move_iterator(iterator_type __i)
945 : _M_current(__i) { }
947 template<
typename _Iter>
948 move_iterator(
const move_iterator<_Iter>& __i)
949 : _M_current(__i.base()) { }
953 {
return _M_current; }
957 {
return std::move(*_M_current); }
961 {
return _M_current; }
973 move_iterator __tmp = *
this;
988 move_iterator __tmp = *
this;
994 operator+(difference_type __n)
const
995 {
return move_iterator(_M_current + __n); }
998 operator+=(difference_type __n)
1005 operator-(difference_type __n)
const
1006 {
return move_iterator(_M_current - __n); }
1009 operator-=(difference_type __n)
1016 operator[](difference_type __n)
const
1017 {
return std::move(_M_current[__n]); }
1023 template<
typename _IteratorL,
typename _IteratorR>
1025 operator==(
const move_iterator<_IteratorL>& __x,
1026 const move_iterator<_IteratorR>& __y)
1027 {
return __x.base() == __y.base(); }
1029 template<
typename _Iterator>
1031 operator==(
const move_iterator<_Iterator>& __x,
1032 const move_iterator<_Iterator>& __y)
1033 {
return __x.base() == __y.base(); }
1035 template<
typename _IteratorL,
typename _IteratorR>
1037 operator!=(
const move_iterator<_IteratorL>& __x,
1038 const move_iterator<_IteratorR>& __y)
1039 {
return !(__x == __y); }
1041 template<
typename _Iterator>
1043 operator!=(
const move_iterator<_Iterator>& __x,
1044 const move_iterator<_Iterator>& __y)
1045 {
return !(__x == __y); }
1047 template<
typename _IteratorL,
typename _IteratorR>
1049 operator<(const move_iterator<_IteratorL>& __x,
1050 const move_iterator<_IteratorR>& __y)
1051 {
return __x.base() < __y.base(); }
1053 template<
typename _Iterator>
1055 operator<(const move_iterator<_Iterator>& __x,
1056 const move_iterator<_Iterator>& __y)
1057 {
return __x.base() < __y.base(); }
1059 template<
typename _IteratorL,
typename _IteratorR>
1061 operator<=(const move_iterator<_IteratorL>& __x,
1062 const move_iterator<_IteratorR>& __y)
1063 {
return !(__y < __x); }
1065 template<
typename _Iterator>
1067 operator<=(const move_iterator<_Iterator>& __x,
1068 const move_iterator<_Iterator>& __y)
1069 {
return !(__y < __x); }
1071 template<
typename _IteratorL,
typename _IteratorR>
1073 operator>(
const move_iterator<_IteratorL>& __x,
1074 const move_iterator<_IteratorR>& __y)
1075 {
return __y < __x; }
1077 template<
typename _Iterator>
1079 operator>(
const move_iterator<_Iterator>& __x,
1080 const move_iterator<_Iterator>& __y)
1081 {
return __y < __x; }
1083 template<
typename _IteratorL,
typename _IteratorR>
1085 operator>=(
const move_iterator<_IteratorL>& __x,
1086 const move_iterator<_IteratorR>& __y)
1087 {
return !(__x < __y); }
1089 template<
typename _Iterator>
1091 operator>=(
const move_iterator<_Iterator>& __x,
1092 const move_iterator<_Iterator>& __y)
1093 {
return !(__x < __y); }
1096 template<
typename _IteratorL,
typename _IteratorR>
1098 operator-(
const move_iterator<_IteratorL>& __x,
1099 const move_iterator<_IteratorR>& __y)
1100 -> decltype(__x.base() - __y.base())
1101 {
return __x.base() - __y.base(); }
1103 template<
typename _Iterator>
1105 operator-(
const move_iterator<_Iterator>& __x,
1106 const move_iterator<_Iterator>& __y)
1107 -> decltype(__x.base() - __y.base())
1108 {
return __x.base() - __y.base(); }
1110 template<
typename _Iterator>
1111 inline move_iterator<_Iterator>
1112 operator+(
typename move_iterator<_Iterator>::difference_type __n,
1113 const move_iterator<_Iterator>& __x)
1114 {
return __x + __n; }
1116 template<
typename _Iterator>
1117 inline move_iterator<_Iterator>
1118 make_move_iterator(
const _Iterator& __i)
1119 {
return move_iterator<_Iterator>(__i); }
1123 _GLIBCXX_END_NAMESPACE_VERSION
1126 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter)
1128 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter)
1129 #endif // __GXX_EXPERIMENTAL_CXX0X__