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 back_insert_iterator&
420 operator=(typename _Container::const_reference __value)
422 container->push_back(__value);
426 #ifdef __GXX_EXPERIMENTAL_CXX0X__
427 back_insert_iterator&
428 operator=(typename _Container::value_type&& __value)
430 container->push_back(std::move(__value));
435 /// Simply returns *this.
436 back_insert_iterator&
440 /// Simply returns *this. (This %iterator does not @a move.)
441 back_insert_iterator&
445 /// Simply returns *this. (This %iterator does not @a move.)
452 * @param x A container of arbitrary type.
453 * @return An instance of back_insert_iterator working on @p x.
455 * This wrapper function helps in creating back_insert_iterator instances.
456 * Typing the name of the %iterator requires knowing the precise full
457 * type of the container, which can be tedious and impedes generic
458 * programming. Using this function lets you take advantage of automatic
459 * template parameter deduction, making the compiler match the correct
462 template<typename _Container>
463 inline back_insert_iterator<_Container>
464 back_inserter(_Container& __x)
465 { return back_insert_iterator<_Container>(__x); }
468 * @brief Turns assignment into insertion.
470 * These are output iterators, constructed from a container-of-T.
471 * Assigning a T to the iterator prepends it to the container using
474 * Tip: Using the front_inserter function to create these iterators can
477 template<typename _Container>
478 class front_insert_iterator
479 : public iterator<output_iterator_tag, void, void, void, void>
482 _Container* container;
485 /// A nested typedef for the type of whatever container you used.
486 typedef _Container container_type;
488 /// The only way to create this %iterator is with a container.
489 explicit front_insert_iterator(_Container& __x) : container(&__x) { }
492 * @param value An instance of whatever type
493 * container_type::const_reference is; presumably a
494 * reference-to-const T for container<T>.
495 * @return This %iterator, for chained operations.
497 * This kind of %iterator doesn't really have a @a position in the
498 * container (you can think of the position as being permanently at
499 * the front, if you like). Assigning a value to the %iterator will
500 * always prepend the value to the front of the container.
502 front_insert_iterator&
503 operator=(typename _Container::const_reference __value)
505 container->push_front(__value);
509 #ifdef __GXX_EXPERIMENTAL_CXX0X__
510 front_insert_iterator&
511 operator=(typename _Container::value_type&& __value)
513 container->push_front(std::move(__value));
518 /// Simply returns *this.
519 front_insert_iterator&
523 /// Simply returns *this. (This %iterator does not @a move.)
524 front_insert_iterator&
528 /// Simply returns *this. (This %iterator does not @a move.)
529 front_insert_iterator
535 * @param x A container of arbitrary type.
536 * @return An instance of front_insert_iterator working on @p x.
538 * This wrapper function helps in creating front_insert_iterator instances.
539 * Typing the name of the %iterator requires knowing the precise full
540 * type of the container, which can be tedious and impedes generic
541 * programming. Using this function lets you take advantage of automatic
542 * template parameter deduction, making the compiler match the correct
545 template<typename _Container>
546 inline front_insert_iterator<_Container>
547 front_inserter(_Container& __x)
548 { return front_insert_iterator<_Container>(__x); }
551 * @brief Turns assignment into insertion.
553 * These are output iterators, constructed from a container-of-T.
554 * Assigning a T to the iterator inserts it in the container at the
555 * %iterator's position, rather than overwriting the value at that
558 * (Sequences will actually insert a @e copy of the value before the
559 * %iterator's position.)
561 * Tip: Using the inserter function to create these iterators can
564 template<typename _Container>
565 class insert_iterator
566 : public iterator<output_iterator_tag, void, void, void, void>
569 _Container* container;
570 typename _Container::iterator iter;
573 /// A nested typedef for the type of whatever container you used.
574 typedef _Container container_type;
577 * The only way to create this %iterator is with a container and an
578 * initial position (a normal %iterator into the container).
580 insert_iterator(_Container& __x, typename _Container::iterator __i)
581 : container(&__x), iter(__i) {}
584 * @param value An instance of whatever type
585 * container_type::const_reference is; presumably a
586 * reference-to-const T for container<T>.
587 * @return This %iterator, for chained operations.
589 * This kind of %iterator maintains its own position in the
590 * container. Assigning a value to the %iterator will insert the
591 * value into the container at the place before the %iterator.
593 * The position is maintained such that subsequent assignments will
594 * insert values immediately after one another. For example,
596 * // vector v contains A and Z
598 * insert_iterator i (v, ++v.begin());
603 * // vector v contains A, 1, 2, 3, and Z
607 operator=(typename _Container::const_reference __value)
609 iter = container->insert(iter, __value);
614 #ifdef __GXX_EXPERIMENTAL_CXX0X__
616 operator=(typename _Container::value_type&& __value)
618 iter = container->insert(iter, std::move(__value));
624 /// Simply returns *this.
629 /// Simply returns *this. (This %iterator does not @a move.)
634 /// Simply returns *this. (This %iterator does not @a move.)
641 * @param x A container of arbitrary type.
642 * @return An instance of insert_iterator working on @p x.
644 * This wrapper function helps in creating insert_iterator instances.
645 * Typing the name of the %iterator requires knowing the precise full
646 * type of the container, which can be tedious and impedes generic
647 * programming. Using this function lets you take advantage of automatic
648 * template parameter deduction, making the compiler match the correct
651 template<typename _Container, typename _Iterator>
652 inline insert_iterator<_Container>
653 inserter(_Container& __x, _Iterator __i)
655 return insert_iterator<_Container>(__x,
656 typename _Container::iterator(__i));
659 // @} group iterators
661 _GLIBCXX_END_NAMESPACE
663 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
665 // This iterator adapter is @a normal in the sense that it does not
666 // change the semantics of any of the operators of its iterator
667 // parameter. Its primary purpose is to convert an iterator that is
668 // not a class, e.g. a pointer, into an iterator that is a class.
669 // The _Container parameter exists solely so that different containers
670 // using this template can instantiate different types, even if the
671 // _Iterator parameter is the same.
672 using std::iterator_traits;
674 template<typename _Iterator, typename _Container>
675 class __normal_iterator
678 _Iterator _M_current;
680 typedef iterator_traits<_Iterator> __traits_type;
683 typedef _Iterator iterator_type;
684 typedef typename __traits_type::iterator_category iterator_category;
685 typedef typename __traits_type::value_type value_type;
686 typedef typename __traits_type::difference_type difference_type;
687 typedef typename __traits_type::reference reference;
688 typedef typename __traits_type::pointer pointer;
690 __normal_iterator() : _M_current(_Iterator()) { }
693 __normal_iterator(const _Iterator& __i) : _M_current(__i) { }
695 // Allow iterator to const_iterator conversion
696 template<typename _Iter>
697 __normal_iterator(const __normal_iterator<_Iter,
698 typename __enable_if<
699 (std::__are_same<_Iter, typename _Container::pointer>::__value),
700 _Container>::__type>& __i)
701 : _M_current(__i.base()) { }
703 // Forward iterator requirements
706 { return *_M_current; }
710 { return _M_current; }
721 { return __normal_iterator(_M_current++); }
723 // Bidirectional iterator requirements
733 { return __normal_iterator(_M_current--); }
735 // Random access iterator requirements
737 operator[](const difference_type& __n) const
738 { return _M_current[__n]; }
741 operator+=(const difference_type& __n)
742 { _M_current += __n; return *this; }
745 operator+(const difference_type& __n) const
746 { return __normal_iterator(_M_current + __n); }
749 operator-=(const difference_type& __n)
750 { _M_current -= __n; return *this; }
753 operator-(const difference_type& __n) const
754 { return __normal_iterator(_M_current - __n); }
758 { return _M_current; }
761 // Note: In what follows, the left- and right-hand-side iterators are
762 // allowed to vary in types (conceptually in cv-qualification) so that
763 // comparison between cv-qualified and non-cv-qualified iterators be
764 // valid. However, the greedy and unfriendly operators in std::rel_ops
765 // will make overload resolution ambiguous (when in scope) if we don't
766 // provide overloads whose operands are of the same type. Can someone
767 // remind me what generic programming is about? -- Gaby
769 // Forward iterator requirements
770 template<typename _IteratorL, typename _IteratorR, typename _Container>
772 operator==(const __normal_iterator<_IteratorL, _Container>& __lhs,
773 const __normal_iterator<_IteratorR, _Container>& __rhs)
774 { return __lhs.base() == __rhs.base(); }
776 template<typename _Iterator, typename _Container>
778 operator==(const __normal_iterator<_Iterator, _Container>& __lhs,
779 const __normal_iterator<_Iterator, _Container>& __rhs)
780 { return __lhs.base() == __rhs.base(); }
782 template<typename _IteratorL, typename _IteratorR, typename _Container>
784 operator!=(const __normal_iterator<_IteratorL, _Container>& __lhs,
785 const __normal_iterator<_IteratorR, _Container>& __rhs)
786 { return __lhs.base() != __rhs.base(); }
788 template<typename _Iterator, typename _Container>
790 operator!=(const __normal_iterator<_Iterator, _Container>& __lhs,
791 const __normal_iterator<_Iterator, _Container>& __rhs)
792 { return __lhs.base() != __rhs.base(); }
794 // Random access iterator requirements
795 template<typename _IteratorL, typename _IteratorR, typename _Container>
797 operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
798 const __normal_iterator<_IteratorR, _Container>& __rhs)
799 { return __lhs.base() < __rhs.base(); }
801 template<typename _Iterator, typename _Container>
803 operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
804 const __normal_iterator<_Iterator, _Container>& __rhs)
805 { return __lhs.base() < __rhs.base(); }
807 template<typename _IteratorL, typename _IteratorR, typename _Container>
809 operator>(const __normal_iterator<_IteratorL, _Container>& __lhs,
810 const __normal_iterator<_IteratorR, _Container>& __rhs)
811 { return __lhs.base() > __rhs.base(); }
813 template<typename _Iterator, typename _Container>
815 operator>(const __normal_iterator<_Iterator, _Container>& __lhs,
816 const __normal_iterator<_Iterator, _Container>& __rhs)
817 { return __lhs.base() > __rhs.base(); }
819 template<typename _IteratorL, typename _IteratorR, typename _Container>
821 operator<=(const __normal_iterator<_IteratorL, _Container>& __lhs,
822 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)
829 { return __lhs.base() <= __rhs.base(); }
831 template<typename _IteratorL, typename _IteratorR, typename _Container>
833 operator>=(const __normal_iterator<_IteratorL, _Container>& __lhs,
834 const __normal_iterator<_IteratorR, _Container>& __rhs)
835 { return __lhs.base() >= __rhs.base(); }
837 template<typename _Iterator, typename _Container>
839 operator>=(const __normal_iterator<_Iterator, _Container>& __lhs,
840 const __normal_iterator<_Iterator, _Container>& __rhs)
841 { return __lhs.base() >= __rhs.base(); }
843 // _GLIBCXX_RESOLVE_LIB_DEFECTS
844 // According to the resolution of DR179 not only the various comparison
845 // operators but also operator- must accept mixed iterator/const_iterator
847 template<typename _IteratorL, typename _IteratorR, typename _Container>
848 #ifdef __GXX_EXPERIMENTAL_CXX0X__
851 operator-(const __normal_iterator<_IteratorL, _Container>& __lhs,
852 const __normal_iterator<_IteratorR, _Container>& __rhs)
853 -> decltype(__lhs.base() - __rhs.base())
855 inline typename __normal_iterator<_IteratorL, _Container>::difference_type
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>
862 inline typename __normal_iterator<_Iterator, _Container>::difference_type
863 operator-(const __normal_iterator<_Iterator, _Container>& __lhs,
864 const __normal_iterator<_Iterator, _Container>& __rhs)
865 { return __lhs.base() - __rhs.base(); }
867 template<typename _Iterator, typename _Container>
868 inline __normal_iterator<_Iterator, _Container>
869 operator+(typename __normal_iterator<_Iterator, _Container>::difference_type
870 __n, const __normal_iterator<_Iterator, _Container>& __i)
871 { return __normal_iterator<_Iterator, _Container>(__i.base() + __n); }
873 _GLIBCXX_END_NAMESPACE
875 #ifdef __GXX_EXPERIMENTAL_CXX0X__
877 _GLIBCXX_BEGIN_NAMESPACE(std)
880 * @addtogroup iterators
884 // 24.4.3 Move iterators
886 * Class template move_iterator is an iterator adapter with the same
887 * behavior as the underlying iterator except that its dereference
888 * operator implicitly converts the value returned by the underlying
889 * iterator's dereference operator to an rvalue reference. Some
890 * generic algorithms can be called with move iterators to replace
891 * copying with moving.
893 template<typename _Iterator>
897 _Iterator _M_current;
899 typedef iterator_traits<_Iterator> __traits_type;
902 typedef _Iterator iterator_type;
903 typedef typename __traits_type::iterator_category iterator_category;
904 typedef typename __traits_type::value_type value_type;
905 typedef typename __traits_type::difference_type difference_type;
907 typedef _Iterator pointer;
908 typedef value_type&& reference;
914 move_iterator(iterator_type __i)
915 : _M_current(__i) { }
917 template<typename _Iter>
918 move_iterator(const move_iterator<_Iter>& __i)
919 : _M_current(__i.base()) { }
923 { return _M_current; }
927 { return std::move(*_M_current); }
931 { return _M_current; }
943 move_iterator __tmp = *this;
958 move_iterator __tmp = *this;
964 operator+(difference_type __n) const
965 { return move_iterator(_M_current + __n); }
968 operator+=(difference_type __n)
975 operator-(difference_type __n) const
976 { return move_iterator(_M_current - __n); }
979 operator-=(difference_type __n)
986 operator[](difference_type __n) const
987 { return std::move(_M_current[__n]); }
990 template<typename _IteratorL, typename _IteratorR>
992 operator==(const move_iterator<_IteratorL>& __x,
993 const move_iterator<_IteratorR>& __y)
994 { return __x.base() == __y.base(); }
996 template<typename _IteratorL, typename _IteratorR>
998 operator!=(const move_iterator<_IteratorL>& __x,
999 const move_iterator<_IteratorR>& __y)
1000 { return !(__x == __y); }
1002 template<typename _IteratorL, typename _IteratorR>
1004 operator<(const move_iterator<_IteratorL>& __x,
1005 const move_iterator<_IteratorR>& __y)
1006 { return __x.base() < __y.base(); }
1008 template<typename _IteratorL, typename _IteratorR>
1010 operator<=(const move_iterator<_IteratorL>& __x,
1011 const move_iterator<_IteratorR>& __y)
1012 { return !(__y < __x); }
1014 template<typename _IteratorL, typename _IteratorR>
1016 operator>(const move_iterator<_IteratorL>& __x,
1017 const move_iterator<_IteratorR>& __y)
1018 { return __y < __x; }
1020 template<typename _IteratorL, typename _IteratorR>
1022 operator>=(const move_iterator<_IteratorL>& __x,
1023 const move_iterator<_IteratorR>& __y)
1024 { return !(__x < __y); }
1027 template<typename _IteratorL, typename _IteratorR>
1029 operator-(const move_iterator<_IteratorL>& __x,
1030 const move_iterator<_IteratorR>& __y)
1031 -> decltype(__x.base() - __y.base())
1032 { return __x.base() - __y.base(); }
1034 template<typename _Iterator>
1035 inline move_iterator<_Iterator>
1036 operator+(typename move_iterator<_Iterator>::difference_type __n,
1037 const move_iterator<_Iterator>& __x)
1038 { return __x + __n; }
1040 template<typename _Iterator>
1041 inline move_iterator<_Iterator>
1042 make_move_iterator(const _Iterator& __i)
1043 { return move_iterator<_Iterator>(__i); }
1045 // @} group iterators
1047 _GLIBCXX_END_NAMESPACE
1049 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) std::make_move_iterator(_Iter)
1051 #define _GLIBCXX_MAKE_MOVE_ITERATOR(_Iter) (_Iter)
1052 #endif // __GXX_EXPERIMENTAL_CXX0X__