1 // Iterators -*- C++ -*-
3 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
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 2, 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 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
34 * Hewlett-Packard Company
36 * Permission to use, copy, modify, distribute and sell this software
37 * and its documentation for any purpose is hereby granted without fee,
38 * provided that the above copyright notice appear in all copies and
39 * that both that copyright notice and this permission notice appear
40 * in supporting documentation. Hewlett-Packard Company makes no
41 * representations about the suitability of this software for any
42 * purpose. It is provided "as is" without express or implied warranty.
45 * Copyright (c) 1996-1998
46 * Silicon Graphics Computer Systems, Inc.
48 * Permission to use, copy, modify, distribute and sell this software
49 * and its documentation for any purpose is hereby granted without fee,
50 * provided that the above copyright notice appear in all copies and
51 * that both that copyright notice and this permission notice appear
52 * in supporting documentation. Silicon Graphics makes no
53 * representations about the suitability of this software for any
54 * purpose. It is provided "as is" without express or implied warranty.
57 /** @file stl_iterator.h
58 * This is an internal header file, included by other library headers.
59 * You should not attempt to use it directly.
61 * This file implements reverse_iterator, back_insert_iterator,
62 * front_insert_iterator, insert_iterator, __normal_iterator, and their
63 * supporting functions and overloaded operators.
66 #ifndef _STL_ITERATOR_H
67 #define _STL_ITERATOR_H 1
69 #include <bits/cpp_type_traits.h>
70 #include <ext/type_traits.h>
71 #include <bits/stl_move.h>
73 _GLIBCXX_BEGIN_NAMESPACE(std
)
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 * 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." [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
>
106 typedef _Iterator iterator_type
;
107 typedef typename iterator_traits
<_Iterator
>::difference_type
109 typedef typename iterator_traits
<_Iterator
>::reference reference
;
110 typedef typename iterator_traits
<_Iterator
>::pointer pointer
;
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 inline typename reverse_iterator
<_IteratorL
>::difference_type
369 operator-(const reverse_iterator
<_IteratorL
>& __x
,
370 const reverse_iterator
<_IteratorR
>& __y
)
371 { return __y
.base() - __x
.base(); }
374 // 24.4.2.2.1 back_insert_iterator
376 * @brief Turns assignment into insertion.
378 * These are output iterators, constructed from a container-of-T.
379 * Assigning a T to the iterator appends it to the container using
382 * Tip: Using the back_inserter function to create these iterators can
385 template<typename _Container
>
386 class back_insert_iterator
387 : public iterator
<output_iterator_tag
, void, void, void, void>
390 _Container
* container
;
393 /// A nested typedef for the type of whatever container you used.
394 typedef _Container container_type
;
396 /// The only way to create this %iterator is with a container.
398 back_insert_iterator(_Container
& __x
) : container(&__x
) { }
401 * @param value An instance of whatever type
402 * container_type::const_reference is; presumably a
403 * reference-to-const T for container<T>.
404 * @return This %iterator, for chained operations.
406 * This kind of %iterator doesn't really have a "position" in the
407 * container (you can think of the position as being permanently at
408 * the end, if you like). Assigning a value to the %iterator will
409 * always append the value to the end of the container.
411 back_insert_iterator
&
412 operator=(typename
_Container::const_reference __value
)
414 container
->push_back(__value
);
418 #ifdef __GXX_EXPERIMENTAL_CXX0X__
419 back_insert_iterator
&
420 operator=(typename
_Container::value_type
&& __value
)
422 container
->push_back(std::move(__value
));
427 /// Simply returns *this.
428 back_insert_iterator
&
432 /// Simply returns *this. (This %iterator does not "move".)
433 back_insert_iterator
&
437 /// Simply returns *this. (This %iterator does not "move".)
444 * @param x A container of arbitrary type.
445 * @return An instance of back_insert_iterator working on @p x.
447 * This wrapper function helps in creating back_insert_iterator instances.
448 * Typing the name of the %iterator requires knowing the precise full
449 * type of the container, which can be tedious and impedes generic
450 * programming. Using this function lets you take advantage of automatic
451 * template parameter deduction, making the compiler match the correct
454 template<typename _Container
>
455 inline back_insert_iterator
<_Container
>
456 back_inserter(_Container
& __x
)
457 { return back_insert_iterator
<_Container
>(__x
); }
460 * @brief Turns assignment into insertion.
462 * These are output iterators, constructed from a container-of-T.
463 * Assigning a T to the iterator prepends it to the container using
466 * Tip: Using the front_inserter function to create these iterators can
469 template<typename _Container
>
470 class front_insert_iterator
471 : public iterator
<output_iterator_tag
, void, void, void, void>
474 _Container
* container
;
477 /// A nested typedef for the type of whatever container you used.
478 typedef _Container container_type
;
480 /// The only way to create this %iterator is with a container.
481 explicit front_insert_iterator(_Container
& __x
) : container(&__x
) { }
484 * @param value An instance of whatever type
485 * container_type::const_reference is; presumably a
486 * reference-to-const T for container<T>.
487 * @return This %iterator, for chained operations.
489 * This kind of %iterator doesn't really have a "position" in the
490 * container (you can think of the position as being permanently at
491 * the front, if you like). Assigning a value to the %iterator will
492 * always prepend the value to the front of the container.
494 front_insert_iterator
&
495 operator=(typename
_Container::const_reference __value
)
497 container
->push_front(__value
);
501 #ifdef __GXX_EXPERIMENTAL_CXX0X__
502 front_insert_iterator
&
503 operator=(typename
_Container::value_type
&& __value
)
505 container
->push_front(std::move(__value
));
510 /// Simply returns *this.
511 front_insert_iterator
&
515 /// Simply returns *this. (This %iterator does not "move".)
516 front_insert_iterator
&
520 /// Simply returns *this. (This %iterator does not "move".)
521 front_insert_iterator
527 * @param x A container of arbitrary type.
528 * @return An instance of front_insert_iterator working on @p x.
530 * This wrapper function helps in creating front_insert_iterator instances.
531 * Typing the name of the %iterator requires knowing the precise full
532 * type of the container, which can be tedious and impedes generic
533 * programming. Using this function lets you take advantage of automatic
534 * template parameter deduction, making the compiler match the correct
537 template<typename _Container
>
538 inline front_insert_iterator
<_Container
>
539 front_inserter(_Container
& __x
)
540 { return front_insert_iterator
<_Container
>(__x
); }
543 * @brief Turns assignment into insertion.
545 * These are output iterators, constructed from a container-of-T.
546 * Assigning a T to the iterator inserts it in the container at the
547 * %iterator's position, rather than overwriting the value at that
550 * (Sequences will actually insert a @e copy of the value before the
551 * %iterator's position.)
553 * Tip: Using the inserter function to create these iterators can
556 template<typename _Container
>
557 class insert_iterator
558 : public iterator
<output_iterator_tag
, void, void, void, void>
561 _Container
* container
;
562 typename
_Container::iterator iter
;
565 /// A nested typedef for the type of whatever container you used.
566 typedef _Container container_type
;
569 * The only way to create this %iterator is with a container and an
570 * initial position (a normal %iterator into the container).
572 insert_iterator(_Container
& __x
, typename
_Container::iterator __i
)
573 : container(&__x
), iter(__i
) {}
576 * @param value An instance of whatever type
577 * container_type::const_reference is; presumably a
578 * reference-to-const T for container<T>.
579 * @return This %iterator, for chained operations.
581 * This kind of %iterator maintains its own position in the
582 * container. Assigning a value to the %iterator will insert the
583 * value into the container at the place before the %iterator.
585 * The position is maintained such that subsequent assignments will
586 * insert values immediately after one another. For example,
588 * // vector v contains A and Z
590 * insert_iterator i (v, ++v.begin());
595 * // vector v contains A, 1, 2, 3, and Z
599 operator=(typename
_Container::const_reference __value
)
601 iter
= container
->insert(iter
, __value
);
606 #ifdef __GXX_EXPERIMENTAL_CXX0X__
608 operator=(typename
_Container::value_type
&& __value
)
610 iter
= container
->insert(iter
, std::move(__value
));
616 /// Simply returns *this.
621 /// Simply returns *this. (This %iterator does not "move".)
626 /// Simply returns *this. (This %iterator does not "move".)
633 * @param x A container of arbitrary type.
634 * @return An instance of insert_iterator working on @p x.
636 * This wrapper function helps in creating insert_iterator instances.
637 * Typing the name of the %iterator requires knowing the precise full
638 * type of the container, which can be tedious and impedes generic
639 * programming. Using this function lets you take advantage of automatic
640 * template parameter deduction, making the compiler match the correct
643 template<typename _Container
, typename _Iterator
>
644 inline insert_iterator
<_Container
>
645 inserter(_Container
& __x
, _Iterator __i
)
647 return insert_iterator
<_Container
>(__x
,
648 typename
_Container::iterator(__i
));
651 _GLIBCXX_END_NAMESPACE
653 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx
)
655 // This iterator adapter is 'normal' in the sense that it does not
656 // change the semantics of any of the operators of its iterator
657 // parameter. Its primary purpose is to convert an iterator that is
658 // not a class, e.g. a pointer, into an iterator that is a class.
659 // The _Container parameter exists solely so that different containers
660 // using this template can instantiate different types, even if the
661 // _Iterator parameter is the same.
662 using std::iterator_traits
;
664 template<typename _Iterator
, typename _Container
>
665 class __normal_iterator
668 _Iterator _M_current
;
671 typedef typename iterator_traits
<_Iterator
>::iterator_category
673 typedef typename iterator_traits
<_Iterator
>::value_type value_type
;
674 typedef typename iterator_traits
<_Iterator
>::difference_type
676 typedef typename iterator_traits
<_Iterator
>::reference reference
;
677 typedef typename iterator_traits
<_Iterator
>::pointer pointer
;
679 typedef _Iterator _Iterator_type
;
681 __normal_iterator() : _M_current(_Iterator()) { }
684 __normal_iterator(const _Iterator
& __i
) : _M_current(__i
) { }
686 // Allow iterator to const_iterator conversion
687 template<typename _Iter
>
688 __normal_iterator(const __normal_iterator
<_Iter
,
689 typename __enable_if
<
690 (std::__are_same
<_Iter
, typename
_Container::pointer
>::__value
),
691 _Container
>::__type
>& __i
)
692 : _M_current(__i
.base()) { }
694 // Forward iterator requirements
697 { return *_M_current
; }
701 { return _M_current
; }
712 { return __normal_iterator(_M_current
++); }
714 // Bidirectional iterator requirements
724 { return __normal_iterator(_M_current
--); }
726 // Random access iterator requirements
728 operator[](const difference_type
& __n
) const
729 { return _M_current
[__n
]; }
732 operator+=(const difference_type
& __n
)
733 { _M_current
+= __n
; return *this; }
736 operator+(const difference_type
& __n
) const
737 { return __normal_iterator(_M_current
+ __n
); }
740 operator-=(const difference_type
& __n
)
741 { _M_current
-= __n
; return *this; }
744 operator-(const difference_type
& __n
) const
745 { return __normal_iterator(_M_current
- __n
); }
749 { return _M_current
; }
752 // Note: In what follows, the left- and right-hand-side iterators are
753 // allowed to vary in types (conceptually in cv-qualification) so that
754 // comparaison between cv-qualified and non-cv-qualified iterators be
755 // valid. However, the greedy and unfriendly operators in std::rel_ops
756 // will make overload resolution ambiguous (when in scope) if we don't
757 // provide overloads whose operands are of the same type. Can someone
758 // remind me what generic programming is about? -- Gaby
760 // Forward iterator requirements
761 template<typename _IteratorL
, typename _IteratorR
, typename _Container
>
763 operator==(const __normal_iterator
<_IteratorL
, _Container
>& __lhs
,
764 const __normal_iterator
<_IteratorR
, _Container
>& __rhs
)
765 { return __lhs
.base() == __rhs
.base(); }
767 template<typename _Iterator
, typename _Container
>
769 operator==(const __normal_iterator
<_Iterator
, _Container
>& __lhs
,
770 const __normal_iterator
<_Iterator
, _Container
>& __rhs
)
771 { return __lhs
.base() == __rhs
.base(); }
773 template<typename _IteratorL
, typename _IteratorR
, typename _Container
>
775 operator!=(const __normal_iterator
<_IteratorL
, _Container
>& __lhs
,
776 const __normal_iterator
<_IteratorR
, _Container
>& __rhs
)
777 { return __lhs
.base() != __rhs
.base(); }
779 template<typename _Iterator
, typename _Container
>
781 operator!=(const __normal_iterator
<_Iterator
, _Container
>& __lhs
,
782 const __normal_iterator
<_Iterator
, _Container
>& __rhs
)
783 { return __lhs
.base() != __rhs
.base(); }
785 // Random access iterator requirements
786 template<typename _IteratorL
, typename _IteratorR
, typename _Container
>
788 operator<(const __normal_iterator
<_IteratorL
, _Container
>& __lhs
,
789 const __normal_iterator
<_IteratorR
, _Container
>& __rhs
)
790 { return __lhs
.base() < __rhs
.base(); }
792 template<typename _Iterator
, typename _Container
>
794 operator<(const __normal_iterator
<_Iterator
, _Container
>& __lhs
,
795 const __normal_iterator
<_Iterator
, _Container
>& __rhs
)
796 { return __lhs
.base() < __rhs
.base(); }
798 template<typename _IteratorL
, typename _IteratorR
, typename _Container
>
800 operator>(const __normal_iterator
<_IteratorL
, _Container
>& __lhs
,
801 const __normal_iterator
<_IteratorR
, _Container
>& __rhs
)
802 { return __lhs
.base() > __rhs
.base(); }
804 template<typename _Iterator
, typename _Container
>
806 operator>(const __normal_iterator
<_Iterator
, _Container
>& __lhs
,
807 const __normal_iterator
<_Iterator
, _Container
>& __rhs
)
808 { return __lhs
.base() > __rhs
.base(); }
810 template<typename _IteratorL
, typename _IteratorR
, typename _Container
>
812 operator<=(const __normal_iterator
<_IteratorL
, _Container
>& __lhs
,
813 const __normal_iterator
<_IteratorR
, _Container
>& __rhs
)
814 { return __lhs
.base() <= __rhs
.base(); }
816 template<typename _Iterator
, typename _Container
>
818 operator<=(const __normal_iterator
<_Iterator
, _Container
>& __lhs
,
819 const __normal_iterator
<_Iterator
, _Container
>& __rhs
)
820 { 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 // _GLIBCXX_RESOLVE_LIB_DEFECTS
835 // According to the resolution of DR179 not only the various comparison
836 // operators but also operator- must accept mixed iterator/const_iterator
838 template<typename _IteratorL
, typename _IteratorR
, typename _Container
>
839 inline typename __normal_iterator
<_IteratorL
, _Container
>::difference_type
840 operator-(const __normal_iterator
<_IteratorL
, _Container
>& __lhs
,
841 const __normal_iterator
<_IteratorR
, _Container
>& __rhs
)
842 { return __lhs
.base() - __rhs
.base(); }
844 template<typename _Iterator
, typename _Container
>
845 inline typename __normal_iterator
<_Iterator
, _Container
>::difference_type
846 operator-(const __normal_iterator
<_Iterator
, _Container
>& __lhs
,
847 const __normal_iterator
<_Iterator
, _Container
>& __rhs
)
848 { return __lhs
.base() - __rhs
.base(); }
850 template<typename _Iterator
, typename _Container
>
851 inline __normal_iterator
<_Iterator
, _Container
>
852 operator+(typename __normal_iterator
<_Iterator
, _Container
>::difference_type
853 __n
, const __normal_iterator
<_Iterator
, _Container
>& __i
)
854 { return __normal_iterator
<_Iterator
, _Container
>(__i
.base() + __n
); }
856 _GLIBCXX_END_NAMESPACE
858 #ifdef __GXX_EXPERIMENTAL_CXX0X__
860 _GLIBCXX_BEGIN_NAMESPACE(std
)
862 // 24.4.3 Move iterators
865 * Class template move_iterator is an iterator adapter with the same
866 * behavior as the underlying iterator except that its dereference
867 * operator implicitly converts the value returned by the underlying
868 * iterator's dereference operator to an rvalue reference. Some
869 * generic algorithms can be called with move iterators to replace
870 * copying with moving.
873 template<typename _Iterator
>
877 _Iterator _M_current
;
880 typedef _Iterator iterator_type
;
881 typedef typename iterator_traits
<_Iterator
>::difference_type
883 typedef typename iterator_traits
<_Iterator
>::pointer pointer
;
884 typedef typename iterator_traits
<_Iterator
>::value_type value_type
;
885 typedef typename iterator_traits
<_Iterator
>::iterator_category
887 typedef value_type
&& reference
;
894 move_iterator(iterator_type __i
)
895 : _M_current(__i
) { }
897 template<typename _Iter
>
898 move_iterator(const move_iterator
<_Iter
>& __i
)
899 : _M_current(__i
.base()) { }
903 { return _M_current
; }
907 { return *_M_current
; }
911 { return _M_current
; }
923 move_iterator __tmp
= *this;
938 move_iterator __tmp
= *this;
944 operator+(difference_type __n
) const
945 { return move_iterator(_M_current
+ __n
); }
948 operator+=(difference_type __n
)
955 operator-(difference_type __n
) const
956 { return move_iterator(_M_current
- __n
); }
959 operator-=(difference_type __n
)
966 operator[](difference_type __n
) const
967 { return _M_current
[__n
]; }
970 template<typename _IteratorL
, typename _IteratorR
>
972 operator==(const move_iterator
<_IteratorL
>& __x
,
973 const move_iterator
<_IteratorR
>& __y
)
974 { return __x
.base() == __y
.base(); }
976 template<typename _IteratorL
, typename _IteratorR
>
978 operator!=(const move_iterator
<_IteratorL
>& __x
,
979 const move_iterator
<_IteratorR
>& __y
)
980 { return !(__x
== __y
); }
982 template<typename _IteratorL
, typename _IteratorR
>
984 operator<(const move_iterator
<_IteratorL
>& __x
,
985 const move_iterator
<_IteratorR
>& __y
)
986 { return __x
.base() < __y
.base(); }
988 template<typename _IteratorL
, typename _IteratorR
>
990 operator<=(const move_iterator
<_IteratorL
>& __x
,
991 const move_iterator
<_IteratorR
>& __y
)
992 { return !(__y
< __x
); }
994 template<typename _IteratorL
, typename _IteratorR
>
996 operator>(const move_iterator
<_IteratorL
>& __x
,
997 const move_iterator
<_IteratorR
>& __y
)
998 { return __y
< __x
; }
1000 template<typename _IteratorL
, typename _IteratorR
>
1002 operator>=(const move_iterator
<_IteratorL
>& __x
,
1003 const move_iterator
<_IteratorR
>& __y
)
1004 { return !(__x
< __y
); }
1006 template<typename _IteratorL
, typename _IteratorR
>
1007 inline typename move_iterator
<_IteratorL
>::difference_type
1008 operator-(const move_iterator
<_IteratorL
>& __x
,
1009 const move_iterator
<_IteratorR
>& __y
)
1010 { return __x
.base() - __y
.base(); }
1012 template<typename _Iterator
>
1013 inline move_iterator
<_Iterator
>
1014 operator+(typename move_iterator
<_Iterator
>::difference_type __n
,
1015 const move_iterator
<_Iterator
>& __x
)
1016 { return __x
+ __n
; }
1018 template<typename _Iterator
>
1019 inline move_iterator
<_Iterator
>
1020 make_move_iterator(const _Iterator
& __i
)
1021 { return move_iterator
<_Iterator
>(__i
); }
1023 _GLIBCXX_END_NAMESPACE
1025 #endif // __GXX_EXPERIMENTAL_CXX0X__