1 // Iterators -*- C++ -*-
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
4 // Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // Under Section 7 of GPL version 3, you are granted additional
18 // permissions described in the GCC Runtime Library Exception, version
19 // 3.1, as published by the Free Software Foundation.
21 // You should have received a copy of the GNU General Public License and
22 // a copy of the GCC Runtime Library Exception along with this program;
23 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 // <http://www.gnu.org/licenses/>.
29 * Hewlett-Packard Company
31 * Permission to use, copy, modify, distribute and sell this software
32 * and its documentation for any purpose is hereby granted without fee,
33 * provided that the above copyright notice appear in all copies and
34 * that both that copyright notice and this permission notice appear
35 * in supporting documentation. Hewlett-Packard Company makes no
36 * representations about the suitability of this software for any
37 * purpose. It is provided "as is" without express or implied warranty.
40 * Copyright (c) 1996-1998
41 * Silicon Graphics Computer Systems, Inc.
43 * Permission to use, copy, modify, distribute and sell this software
44 * and its documentation for any purpose is hereby granted without fee,
45 * provided that the above copyright notice appear in all copies and
46 * that both that copyright notice and this permission notice appear
47 * in supporting documentation. Silicon Graphics makes no
48 * representations about the suitability of this software for any
49 * purpose. It is provided "as is" without express or implied warranty.
52 /** @file stl_iterator.h
53 * This is an internal header file, included by other library headers.
54 * You should not attempt to use it directly.
56 * This file implements reverse_iterator, back_insert_iterator,
57 * front_insert_iterator, insert_iterator, __normal_iterator, and their
58 * supporting functions and overloaded operators.
61 #ifndef _STL_ITERATOR_H
62 #define _STL_ITERATOR_H 1
64 #include <bits/cpp_type_traits.h>
65 #include <ext/type_traits.h>
66 #include <bits/move.h>
68 _GLIBCXX_BEGIN_NAMESPACE(std)
71 * @addtogroup iterators
75 // 24.4.1 Reverse iterators
77 * Bidirectional and random access iterators have corresponding reverse
78 * %iterator adaptors that iterate through the data structure in the
79 * opposite direction. They have the same signatures as the corresponding
80 * iterators. The fundamental relation between a reverse %iterator and its
81 * corresponding %iterator @c i is established by the identity:
83 * &*(reverse_iterator(i)) == &*(i - 1)
86 * <em>This mapping is dictated by the fact that while there is always a
87 * pointer past the end of an array, there might not be a valid pointer
88 * before the beginning of an array.</em> [24.4.1]/1,2
90 * Reverse iterators can be tricky and surprising at first. Their
91 * semantics make sense, however, and the trickiness is a side effect of
92 * the requirement that the iterators must be safe.
94 template<typename _Iterator>
95 class reverse_iterator
96 : public iterator<typename iterator_traits<_Iterator>::iterator_category,
97 typename iterator_traits<_Iterator>::value_type,
98 typename iterator_traits<_Iterator>::difference_type,
99 typename iterator_traits<_Iterator>::pointer,
100 typename iterator_traits<_Iterator>::reference>
105 typedef iterator_traits<_Iterator> __traits_type;
108 typedef _Iterator iterator_type;
109 typedef typename __traits_type::difference_type difference_type;
110 typedef typename __traits_type::pointer pointer;
111 typedef typename __traits_type::reference reference;
114 * The default constructor default-initializes member @p current.
115 * If it is a pointer, that means it is zero-initialized.
117 // _GLIBCXX_RESOLVE_LIB_DEFECTS
118 // 235 No specification of default ctor for reverse_iterator
119 reverse_iterator() : current() { }
122 * This %iterator will move in the opposite direction that @p x does.
125 reverse_iterator(iterator_type __x) : current(__x) { }
128 * The copy constructor is normal.
130 reverse_iterator(const reverse_iterator& __x)
131 : current(__x.current) { }
134 * A reverse_iterator across other types can be copied in the normal
137 template<typename _Iter>
138 reverse_iterator(const reverse_iterator<_Iter>& __x)
139 : current(__x.base()) { }
142 * @return @c current, the %iterator used for underlying work.
156 _Iterator __tmp = current;
167 { return &(operator*()); }
189 reverse_iterator __tmp = *this;
214 reverse_iterator __tmp = *this;
225 operator+(difference_type __n) const
226 { return reverse_iterator(current - __n); }
234 operator+=(difference_type __n)
246 operator-(difference_type __n) const
247 { return reverse_iterator(current + __n); }
255 operator-=(difference_type __n)
267 operator[](difference_type __n) const
268 { return *(*this + __n); }
273 * @param x A %reverse_iterator.
274 * @param y A %reverse_iterator.
275 * @return A simple bool.
277 * Reverse iterators forward many operations to their underlying base()
278 * iterators. Others are implemented in terms of one another.
281 template<typename _Iterator>
283 operator==(const reverse_iterator<_Iterator>& __x,
284 const reverse_iterator<_Iterator>& __y)
285 { return __x.base() == __y.base(); }
287 template<typename _Iterator>
289 operator<(const reverse_iterator<_Iterator>& __x,
290 const reverse_iterator<_Iterator>& __y)
291 { return __y.base() < __x.base(); }
293 template<typename _Iterator>
295 operator!=(const reverse_iterator<_Iterator>& __x,
296 const reverse_iterator<_Iterator>& __y)
297 { return !(__x == __y); }
299 template<typename _Iterator>
301 operator>(const reverse_iterator<_Iterator>& __x,
302 const reverse_iterator<_Iterator>& __y)
303 { return __y < __x; }
305 template<typename _Iterator>
307 operator<=(const reverse_iterator<_Iterator>& __x,
308 const reverse_iterator<_Iterator>& __y)
309 { return !(__y < __x); }
311 template<typename _Iterator>
313 operator>=(const reverse_iterator<_Iterator>& __x,
314 const reverse_iterator<_Iterator>& __y)
315 { return !(__x < __y); }
317 template<typename _Iterator>
318 inline typename reverse_iterator<_Iterator>::difference_type
319 operator-(const reverse_iterator<_Iterator>& __x,
320 const reverse_iterator<_Iterator>& __y)
321 { return __y.base() - __x.base(); }
323 template<typename _Iterator>
324 inline reverse_iterator<_Iterator>
325 operator+(typename reverse_iterator<_Iterator>::difference_type __n,
326 const reverse_iterator<_Iterator>& __x)
327 { return reverse_iterator<_Iterator>(__x.base() - __n); }
329 // _GLIBCXX_RESOLVE_LIB_DEFECTS
330 // DR 280. Comparison of reverse_iterator to const reverse_iterator.
331 template<typename _IteratorL, typename _IteratorR>
333 operator==(const reverse_iterator<_IteratorL>& __x,
334 const reverse_iterator<_IteratorR>& __y)
335 { return __x.base() == __y.base(); }
337 template<typename _IteratorL, typename _IteratorR>
339 operator<(const reverse_iterator<_IteratorL>& __x,
340 const reverse_iterator<_IteratorR>& __y)
341 { return __y.base() < __x.base(); }
343 template<typename _IteratorL, typename _IteratorR>
345 operator!=(const reverse_iterator<_IteratorL>& __x,
346 const reverse_iterator<_IteratorR>& __y)
347 { return !(__x == __y); }
349 template<typename _IteratorL, typename _IteratorR>
351 operator>(const reverse_iterator<_IteratorL>& __x,
352 const reverse_iterator<_IteratorR>& __y)
353 { return __y < __x; }
355 template<typename _IteratorL, typename _IteratorR>
357 operator<=(const reverse_iterator<_IteratorL>& __x,
358 const reverse_iterator<_IteratorR>& __y)
359 { return !(__y < __x); }
361 template<typename _IteratorL, typename _IteratorR>
363 operator>=(const reverse_iterator<_IteratorL>& __x,
364 const reverse_iterator<_IteratorR>& __y)
365 { return !(__x < __y); }
367 template<typename _IteratorL, typename _IteratorR>
368 #ifdef __GXX_EXPERIMENTAL_CXX0X__
371 operator-(const reverse_iterator<_IteratorL>& __x,
372 const reverse_iterator<_IteratorR>& __y)
373 -> decltype(__y.base() - __x.base())
375 inline typename reverse_iterator<_IteratorL>::difference_type
376 operator-(const reverse_iterator<_IteratorL>& __x,
377 const reverse_iterator<_IteratorR>& __y)
379 { return __y.base() - __x.base(); }
382 // 24.4.2.2.1 back_insert_iterator
384 * @brief Turns assignment into insertion.
386 * These are output iterators, constructed from a container-of-T.
387 * Assigning a T to the iterator appends it to the container using
390 * Tip: Using the back_inserter function to create these iterators can
393 template<typename _Container>
394 class back_insert_iterator
395 : public iterator<output_iterator_tag, void, void, void, void>
398 _Container* container;
401 /// A nested typedef for the type of whatever container you used.
402 typedef _Container container_type;
404 /// The only way to create this %iterator is with a container.
406 back_insert_iterator(_Container& __x) : container(&__x) { }
409 * @param value An instance of whatever type
410 * container_type::const_reference is; presumably a
411 * reference-to-const T for container<T>.
412 * @return This %iterator, for chained operations.
414 * This kind of %iterator doesn't really have a @a position in the
415 * container (you can think of the position as being permanently at
416 * the end, if you like). Assigning a value to the %iterator will
417 * always append the value to the end of the container.
419 #ifndef __GXX_EXPERIMENTAL_CXX0X__
420 back_insert_iterator&
421 operator=(typename _Container::const_reference __value)
423 container->push_back(__value);
427 back_insert_iterator&
428 operator=(const typename _Container::value_type& __value)
430 container->push_back(__value);
434 back_insert_iterator&
435 operator=(typename _Container::value_type&& __value)
437 container->push_back(std::move(__value));
442 /// Simply returns *this.
443 back_insert_iterator&
447 /// Simply returns *this. (This %iterator does not @a move.)
448 back_insert_iterator&
452 /// Simply returns *this. (This %iterator does not @a move.)
459 * @param x A container of arbitrary type.
460 * @return An instance of back_insert_iterator working on @p x.
462 * This wrapper function helps in creating back_insert_iterator instances.
463 * Typing the name of the %iterator requires knowing the precise full
464 * type of the container, which can be tedious and impedes generic
465 * programming. Using this function lets you take advantage of automatic
466 * template parameter deduction, making the compiler match the correct
469 template<typename _Container>
470 inline back_insert_iterator<_Container>
471 back_inserter(_Container& __x)
472 { return back_insert_iterator<_Container>(__x); }
475 * @brief Turns assignment into insertion.
477 * These are output iterators, constructed from a container-of-T.
478 * Assigning a T to the iterator prepends it to the container using
481 * Tip: Using the front_inserter function to create these iterators can
484 template<typename _Container>
485 class front_insert_iterator
486 : public iterator<output_iterator_tag, void, void, void, void>
489 _Container* container;
492 /// A nested typedef for the type of whatever container you used.
493 typedef _Container container_type;
495 /// The only way to create this %iterator is with a container.
496 explicit front_insert_iterator(_Container& __x) : container(&__x) { }
499 * @param value An instance of whatever type
500 * container_type::const_reference is; presumably a
501 * reference-to-const T for container<T>.
502 * @return This %iterator, for chained operations.
504 * This kind of %iterator doesn't really have a @a position in the
505 * container (you can think of the position as being permanently at
506 * the front, if you like). Assigning a value to the %iterator will
507 * always prepend the value to the front of the container.
509 #ifndef __GXX_EXPERIMENTAL_CXX0X__
510 front_insert_iterator&
511 operator=(typename _Container::const_reference __value)
513 container->push_front(__value);
517 front_insert_iterator&
518 operator=(const typename _Container::value_type& __value)
520 container->push_front(__value);
524 front_insert_iterator&
525 operator=(typename _Container::value_type&& __value)
527 container->push_front(std::move(__value));
532 /// Simply returns *this.
533 front_insert_iterator&
537 /// Simply returns *this. (This %iterator does not @a move.)
538 front_insert_iterator&
542 /// Simply returns *this. (This %iterator does not @a move.)
543 front_insert_iterator
549 * @param x A container of arbitrary type.
550 * @return An instance of front_insert_iterator working on @p x.
552 * This wrapper function helps in creating front_insert_iterator instances.
553 * Typing the name of the %iterator requires knowing the precise full
554 * type of the container, which can be tedious and impedes generic
555 * programming. Using this function lets you take advantage of automatic
556 * template parameter deduction, making the compiler match the correct
559 template<typename _Container>
560 inline front_insert_iterator<_Container>
561 front_inserter(_Container& __x)
562 { return front_insert_iterator<_Container>(__x); }
565 * @brief Turns assignment into insertion.
567 * These are output iterators, constructed from a container-of-T.
568 * Assigning a T to the iterator inserts it in the container at the
569 * %iterator's position, rather than overwriting the value at that
572 * (Sequences will actually insert a @e copy of the value before the
573 * %iterator's position.)
575 * Tip: Using the inserter function to create these iterators can
578 template<typename _Container>
579 class insert_iterator
580 : public iterator<output_iterator_tag, void, void, void, void>
583 _Container* container;
584 typename _Container::iterator iter;
587 /// A nested typedef for the type of whatever container you used.
588 typedef _Container container_type;
591 * The only way to create this %iterator is with a container and an
592 * initial position (a normal %iterator into the container).
594 insert_iterator(_Container& __x, typename _Container::iterator __i)
595 : container(&__x), iter(__i) {}
598 * @param value An instance of whatever type
599 * container_type::const_reference is; presumably a
600 * reference-to-const T for container<T>.
601 * @return This %iterator, for chained operations.
603 * This kind of %iterator maintains its own position in the
604 * container. Assigning a value to the %iterator will insert the
605 * value into the container at the place before the %iterator.
607 * The position is maintained such that subsequent assignments will
608 * insert values immediately after one another. For example,
610 * // vector v contains A and Z
612 * insert_iterator i (v, ++v.begin());
617 * // vector v contains A, 1, 2, 3, and Z
620 #ifndef __GXX_EXPERIMENTAL_CXX0X__
622 operator=(typename _Container::const_reference __value)
624 iter = container->insert(iter, __value);
630 operator=(const typename _Container::value_type& __value)
632 iter = container->insert(iter, __value);
638 operator=(typename _Container::value_type&& __value)
640 iter = container->insert(iter, std::move(__value));
646 /// Simply returns *this.
651 /// Simply returns *this. (This %iterator does not @a move.)
656 /// Simply returns *this. (This %iterator does not @a move.)
663 * @param x A container of arbitrary type.
664 * @return An instance of insert_iterator working on @p x.
666 * This wrapper function helps in creating insert_iterator instances.
667 * Typing the name of the %iterator requires knowing the precise full
668 * type of the container, which can be tedious and impedes generic
669 * programming. Using this function lets you take advantage of automatic
670 * template parameter deduction, making the compiler match the correct
673 template<typename _Container, typename _Iterator>
674 inline insert_iterator<_Container>
675 inserter(_Container& __x, _Iterator __i)
677 return insert_iterator<_Container>(__x,
678 typename _Container::iterator(__i));
681 // @} group iterators
683 _GLIBCXX_END_NAMESPACE
685 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
687 // This iterator adapter is @a normal in the sense that it does not
688 // change the semantics of any of the operators of its iterator
689 // parameter. Its primary purpose is to convert an iterator that is
690 // not a class, e.g. a pointer, into an iterator that is a class.
691 // The _Container parameter exists solely so that different containers
692 // using this template can instantiate different types, even if the
693 // _Iterator parameter is the same.
694 using std::iterator_traits;
696 template<typename _Iterator, typename _Container>
697 class __normal_iterator
700 _Iterator _M_current;
702 typedef iterator_traits<_Iterator> __traits_type;
705 typedef _Iterator iterator_type;
706 typedef typename __traits_type::iterator_category iterator_category;
707 typedef typename __traits_type::value_type value_type;
708 typedef typename __traits_type::difference_type difference_type;
709 typedef typename __traits_type::reference reference;
710 typedef typename __traits_type::pointer pointer;
712 __normal_iterator() : _M_current(_Iterator()) { }
715 __normal_iterator(const _Iterator& __i) : _M_current(__i) { }
717 // Allow iterator to const_iterator conversion
718 template<typename _Iter>
719 __normal_iterator(const __normal_iterator<_Iter,
720 typename __enable_if<
721 (std::__are_same<_Iter, typename _Container::pointer>::__value),
722 _Container>::__type>& __i)
723 : _M_current(__i.base()) { }
725 // Forward iterator requirements
728 { return *_M_current; }
732 { return _M_current; }
743 { return __normal_iterator(_M_current++); }
745 // Bidirectional iterator requirements
755 { return __normal_iterator(_M_current--); }
757 // Random access iterator requirements
759 operator[](const difference_type& __n) const
760 { return _M_current[__n]; }
763 operator+=(const difference_type& __n)
764 { _M_current += __n; return *this; }
767 operator+(const difference_type& __n) const
768 { return __normal_iterator(_M_current + __n); }
771 operator-=(const difference_type& __n)
772 { _M_current -= __n; return *this; }
775 operator-(const difference_type& __n) const
776 { return __normal_iterator(_M_current - __n); }
780 { return _M_current; }
783 // Note: In what follows, the left- and right-hand-side iterators are
784 // allowed to vary in types (conceptually in cv-qualification) so that
785 // comparison between cv-qualified and non-cv-qualified iterators be
786 // valid. However, the greedy and unfriendly operators in std::rel_ops
787 // will make overload resolution ambiguous (when in scope) if we don't
788 // provide overloads whose operands are of the same type. Can someone
789 // remind me what generic programming is about? -- Gaby
791 // Forward iterator requirements
792 template<typename _IteratorL, typename _IteratorR, typename _Container>
794 operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
795 const __normal_iterator<_IteratorR, _Container>& __rhs)
796 { return __lhs.base() == __rhs.base(); }
798 template<typename _Iterator, typename _Container>
800 operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
801 const __normal_iterator<_Iterator, _Container>& __rhs)
802 { return __lhs.base() == __rhs.base(); }
804 template<typename _IteratorL, typename _IteratorR, typename _Container>
806 operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
807 const __normal_iterator<_IteratorR, _Container>& __rhs)
808 { return __lhs.base() != __rhs.base(); }
810 template<typename _Iterator, typename _Container>
812 operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
813 const __normal_iterator<_Iterator, _Container>& __rhs)
814 { return __lhs.base() != __rhs.base(); }
816 // Random access iterator requirements
817 template<typename _IteratorL, typename _IteratorR, typename _Container>
819 operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
820 const __normal_iterator<_IteratorR, _Container>& __rhs)
821 { return __lhs.base() < __rhs.base(); }
823 template<typename _Iterator, typename _Container>
825 operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
826 const __normal_iterator<_Iterator, _Container>& __rhs)
827 { return __lhs.base() < __rhs.base(); }
829 template<typename _IteratorL, typename _IteratorR, typename _Container>
831 operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
832 const __normal_iterator<_IteratorR, _Container>& __rhs)
833 { return __lhs.base() > __rhs.base(); }
835 template<typename _Iterator, typename _Container>
837 operator>(const __normal_iterator<_Iterator, _Container>& __lhs,
838 const __normal_iterator<_Iterator, _Container>& __rhs)
839 { return __lhs.base() > __rhs.base(); }
841 template<typename _IteratorL, typename _IteratorR, typename _Container>
843 operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
844 const __normal_iterator<_IteratorR, _Container>& __rhs)
845 { return __lhs.base() <= __rhs.base(); }
847 template<typename _Iterator, typename _Container>
849 operator<=(const __normal_iterator<_Iterator, _Container>& __lhs,
850 const __normal_iterator<_Iterator, _Container>& __rhs)
851 { return __lhs.base() <= __rhs.base(); }
853 template<typename _IteratorL, typename _IteratorR, typename _Container>
855 operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
856 const __normal_iterator<_IteratorR, _Container>& __rhs)
857 { return __lhs.base() >= __rhs.base(); }
859 template<typename _Iterator, typename _Container>
861 operator>=(const __normal_iterator<_Iterator, _Container>& __lhs,
862 const __normal_iterator<_Iterator, _Container>& __rhs)
863 { return __lhs.base() >= __rhs.base(); }
865 // _GLIBCXX_RESOLVE_LIB_DEFECTS
866 // According to the resolution of DR179 not only the various comparison
867 // operators but also operator- must accept mixed iterator/const_iterator
869 template<typename _IteratorL, typename _IteratorR, typename _Container>
870 #ifdef __GXX_EXPERIMENTAL_CXX0X__
873 operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
874 const __normal_iterator<_IteratorR, _Container>& __rhs)
875 -> decltype(__lhs.base() - __rhs.base())
877 inline typename __normal_iterator<_IteratorL, _Container>::difference_type
878 operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
879 const __normal_iterator<_IteratorR, _Container>& __rhs)
881 { return __lhs.base() - __rhs.base(); }
883 template<typename _Iterator, typename _Container>
884 inline typename __normal_iterator<_Iterator, _Container>::difference_type
885 operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
886 const __normal_iterator<_Iterator, _Container>& __rhs)
887 { return __lhs.base() - __rhs.base(); }
889 template<typename _Iterator, typename _Container>
890 inline __normal_iterator<_Iterator, _Container>
891 operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
892 __n, const __normal_iterator<_Iterator, _Container>& __i)
893 { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
895 _GLIBCXX_END_NAMESPACE
897 #ifdef __GXX_EXPERIMENTAL_CXX0X__
899 _GLIBCXX_BEGIN_NAMESPACE(std)
902 * @addtogroup iterators
906 // 24.4.3 Move iterators
908 * Class template move_iterator is an iterator adapter with the same
909 * behavior as the underlying iterator except that its dereference
910 * operator implicitly converts the value returned by the underlying
911 * iterator's dereference operator to an rvalue reference. Some
912 * generic algorithms can be called with move iterators to replace
913 * copying with moving.
915 template<typename _Iterator>
919 _Iterator _M_current;
921 typedef iterator_traits<_Iterator> __traits_type;
924 typedef _Iterator iterator_type;
925 typedef typename __traits_type::iterator_category iterator_category;
926 typedef typename __traits_type::value_type value_type;
927 typedef typename __traits_type::difference_type difference_type;
929 typedef _Iterator pointer;
930 typedef value_type&& reference;
936 move_iterator(iterator_type __i)
937 : _M_current(__i) { }
939 template<typename _Iter>
940 move_iterator(const move_iterator<_Iter>& __i)
941 : _M_current(__i.base()) { }
945 { return _M_current; }
949 { return std::move(*_M_current); }
953 { return _M_current; }
965 move_iterator __tmp = *this;
980 move_iterator __tmp = *this;
986 operator+(difference_type __n) const
987 { return move_iterator(_M_current + __n); }
990 operator+=(difference_type __n)
997 operator-(difference_type __n) const
998 { return move_iterator(_M_current - __n); }
1001 operator-=(difference_type __n)
1008 operator[](difference_type __n) const
1009 { return std::move(_M_current[__n]); }
1012 template<typename _IteratorL, typename _IteratorR>
1014 operator==(const move_iterator<_IteratorL>& __x,
1015 const move_iterator<_IteratorR>& __y)
1016 { return __x.base() == __y.base(); }
1018 template<typename _IteratorL, typename _IteratorR>
1020 operator!=(const move_iterator<_IteratorL>& __x,
1021 const move_iterator<_IteratorR>& __y)
1022 { return !(__x == __y); }
1024 template<typename _IteratorL, typename _IteratorR>
1026 operator<(const move_iterator<_IteratorL>& __x,
1027 const move_iterator<_IteratorR>& __y)
1028 { return __x.base() < __y.base(); }
1030 template<typename _IteratorL, typename _IteratorR>
1032 operator<=(const move_iterator<_IteratorL>& __x,
1033 const move_iterator<_IteratorR>& __y)
1034 { return !(__y < __x); }
1036 template<typename _IteratorL, typename _IteratorR>
1038 operator>(const move_iterator<_IteratorL>& __x,
1039 const move_iterator<_IteratorR>& __y)
1040 { return __y < __x; }
1042 template<typename _IteratorL, typename _IteratorR>
1044 operator>=(const move_iterator<_IteratorL>& __x,
1045 const move_iterator<_IteratorR>& __y)
1046 { return !(__x < __y); }
1049 template<typename _IteratorL, typename _IteratorR>
1051 operator-(const move_iterator<_IteratorL>& __x,
1052 const move_iterator<_IteratorR>& __y)
1053 -> decltype(__x.base() - __y.base())
1054 { return __x.base() - __y.base(); }
1056 template<typename _Iterator>
1057 inline move_iterator<_Iterator>
1058 operator+(typename move_iterator<_Iterator>::difference_type __n,
1059 const move_iterator<_Iterator>& __x)
1060 { return __x + __n; }
1062 template<typename _Iterator>
1063 inline move_iterator<_Iterator>
1064 make_move_iterator(const _Iterator& __i)
1065 { return move_iterator<_Iterator>(__i); }
1067 // @} group iterators
1069 _GLIBCXX_END_NAMESPACE
1071 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter)
1073 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter)
1074 #endif // __GXX_EXPERIMENTAL_CXX0X__