<html>
<head>
<title>Rvalue Reference Recommendations for Chapter 24</title>
<style>
p {text-align:justify}
li {text-align:justify}
blockquote.note
{
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
}
ins {background-color:#FFFFA0}
del {background-color:#FFFFA0}
</style>
</head>

<body>

<address align=right>
Document number: N1859=05-0119<br>
<br>
<a href="mailto:hinnant@twcny.rr.com">Howard E. Hinnant</a><br>
2005-08-26
</address>
<hr>

<h1 align=center>Rvalue Reference Recommendations for Chapter 24</h1>

<h2>Contents</h2>

<ul>
<li><a href="#Introduction">Introduction</a></li>
<li><a href="#24.2">24.2 - Header <tt>&lt;iterator&gt;</tt> synopsis</a></li>
<li>
<a href="#24.4 - Predefined iterators">24.4 - Predefined iterators</a>
	<ul>
	<li>
	<a href="#24.4.2 - Insert iterators">24.4.2 - Insert iterators</a>
		<ul>
		<li>
		<a href="#24.4.2.1 - Class template back_insert_iterator">24.4.2.1 - Class template <tt>back_insert_iterator</tt></a>
		</li>
		<li>
		<a href="#24.4.2.2 - back_insert_iterator operations">24.4.2.2 - <tt>back_insert_iterator</tt> operations</a>
			<ul>
			<li>
			<a href="#24.4.2.2.2 - back_insert_iterator::operator_equals">24.4.2.2.2 - <tt>back_insert_iterator::operator=</tt></a>
			</li>
			</ul>
		</li>
		<li>
		<a href="#24.4.2.3 - Class template front_insert_iterator">24.4.2.3 - Class template <tt>front_insert_iterator</tt></a>
		</li>
		<li>
		<a href="#24.4.2.4 - front_insert_iterator operations">24.4.2.4 - <tt>front_insert_iterator</tt> operations</a>
			<ul>
			<li>
			<a href="#24.4.2.4.2 - front_insert_iterator::operator_equals">24.4.2.4.2 - <tt>front_insert_iterator::operator=</tt></a>
			</li>
			</ul>
		</li>
		<li>
		<a href="#24.4.2.5 - Class template insert_iterator">24.4.2.5 - Class template <tt>insert_iterator</tt></a>
		</li>
		<li>
		<a href="#24.4.2.6 - insert_iterator operations">24.4.2.6 - <tt>insert_iterator</tt> operations</a>
			<ul>
			<li>
			<a href="#24.4.2.6.2 - insert_iterator::operator_equals">24.4.2.6.2 - <tt>insert_iterator::operator=</tt></a>
			</li>
			</ul>
		</li>
		</ul>
	</li>
	<li>
	<a href="#24.4.3 - Class template move_iterator">24.4.3 - Class template <tt>move_iterator</tt></a>
		<ul>
		<li><a href="#24.4.3.1 - move_iterator requirements">24.4.3.1 - <tt>move_iterator</tt> requirements</a></li>
		<li>
		<a href="#24.4.3.2 - move_iterator operations">24.4.3.2 - <tt>move_iterator</tt> operations</a>
			<ul>
			<li><a href="#24.4.3.2.1 - move_iterator constructors">24.4.3.2.1 - <tt>move_iterator</tt> constructors</a></li>
			<li><a href="#24.4.3.2.2 - move_iterator assignment">24.4.3.2.2 - <tt>move_iterator</tt> assignment</a></li>
			<li><a href="#24.4.3.2.3 - move_iterator access">24.4.3.2.3 - <tt>move_iterator</tt> access</a></li>
			<li><a href="#24.4.3.2.4 - move_iterator traversal">24.4.3.2.4 - <tt>move_iterator</tt> traversal</a></li>
			<li><a href="#24.4.3.2.5 - move_iterator comparison">24.4.3.2.5 - <tt>move_iterator</tt> comparison</a></li>
			<li><a href="#24.4.3.2.6 - make_move_iterator">24.4.3.2.6 - <tt>make_move_iterator</tt></a></li>
			</ul>
		</li>
		</ul>
	</li>
	</ul>
</li>
</ul>

<h2>Related papers</h2>

<p>
<a href="n1856.html">Rvalue Reference Recommendations for Chapter 20</a><br>
<a href="n1857.html">Rvalue Reference Recommendations for Chapter 21</a><br>
<a href="n1858.html">Rvalue Reference Recommendations for Chapter 23</a><br>
<a href="n1860.html">Rvalue Reference Recommendations for Chapter 25</a><br>
<a href="n1861.html">Rvalue Reference Recommendations for Chapter 26</a><br>
<a href="n1862.html">Rvalue Reference Recommendations for Chapter 27</a>
</p>

<h2><a name="Introduction"></a>Introduction</h2>

<p>
This paper recommends proposed wording with respect to the
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1690.html">rvalue
reference</a> for the
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1804.pdf">C++0X
working draft</a>.
This paper restricts its scope to Chapter 24 "Iterators library" for the purpose
of breaking the library work associated with the rvalue reference up into
manageable chunks. This paper largely follows the lead of
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1771.html">N1771:
Impact of the rvalue reference on the Standard Library</a>, but adds more detail
as appropriate.  Refer to N1771 for detailed motivation for these changes.
</p>

<p>
With the exception of this introduction, all non-proposed wording will have a
background color and formatting that
</p>
<blockquote class="note">
looks like this, so that motivation and description is more easily distinguished
from proposed wording.
</blockquote>
<p>
In the proposed wording below, text to be inserted is formatted like
<ins>this</ins>, while wording to be deleted is formatted like <del>this</del>.
</p>

<p>
The proposed wording in this paper:
</p>

<ul>
<li>Introduces an iterator adaptor <tt>move_iterator</tt>.</li>
<li>Updates the insert iterators to work with rvalues.</li>
</ul>

<h2><a name="24.2"></a>24.2 - Header <tt>&lt;iterator&gt;</tt> synopsis</h2>

<blockquote><pre>
  template &lt;class Container&gt; class insert_iterator;
  template &lt;class Container, class Iterator&gt;
    insert_iterator&lt;Container&gt; inserter(Container&amp; x, Iterator i);

  <ins>template &lt;class Iterator&gt; class move_iterator;

  template &lt;class Iterator1, class Iterator2&gt;
  bool
  operator==(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);

  template &lt;class Iterator1, class Iterator2&gt;
  bool
  operator!=(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);

  template &lt;class Iterator1, class Iterator2&gt;
  bool
  operator&lt; (const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);

  template &lt;class Iterator1, class Iterator2&gt;
  bool
  operator&lt;=(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator&gt;& y);

  template &lt;class Iterator1, class Iterator2&gt;
  bool
  operator&gt; (const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);

  template &lt;class Iterator1, class Iterator2&gt;
  bool
  operator&gt;=(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);

  template &lt;class Iterator1, class Iterator2&gt;
  typename move_iterator&lt;Iterator&gt;::difference_type
  operator-(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);

  template &lt;class Iterator&gt;
  move_iterator&lt;Iterator&gt;
  operator+(typename move_iterator&lt;Iterator&gt;::difference_type n,
            const move_iterator&lt;Iterator&gt;& x);

  template &lt;class Iterator&gt;
  move_iterator&lt;Iterator&gt;
  make_move_iterator(const Iterator& i);</ins>
</pre></blockquote>

<h2><a name="24.4 - Predefined iterators"></a>24.4 - Predefined iterators</h2>
<h3><a name="24.4.2 - Insert iterators"></a>24.4.2 - Insert iterators</h3>

<blockquote class="note">
<p>
Consider the following code: </p>

<blockquote><pre>
vector&lt;unique_ptr&lt;int&gt; &gt; v1, v2;
...
remove_copy(make_move_iterator(v1.begin()), make_move_iterator(v1.end()),
            back_inserter(v2), unique_ptr&lt;int&gt;());
</pre></blockquote>

<p>
In order for the above code to work, the <tt>back_insert_iterator</tt> formed by
<tt>back_inserter</tt> must <i>move assign</i> instead of copy assign from
rvalues.  This is accomplished by overloading the <tt>back_insert_iterator</tt>
assignment operator for both <tt>const value_type&amp;</tt> and
<tt>value_type&amp;&amp;</tt> parameters, with the latter performing a move
assignment. </p>

<p>
Similar additions are also needed for <tt>front_insert_iterator</tt> and
<tt>insert_iterator</tt>. </p>

</blockquote>

<h4><a name="24.4.2.1 - Class template back_insert_iterator"></a>24.4.2.1 - Class template <tt>back_insert_iterator</tt></h4>

<blockquote><pre>
  template &lt;class Container&gt;
  class back_insert_iterator :
        public iterator&lt;output_iterator_tag,void,void,void,void&gt; {
  protected:
    Container* container;

  public:
    typedef Container container_type;
    explicit back_insert_iterator(Container&amp; x);
    back_insert_iterator<del>&lt;Container&gt;</del>&amp;
      operator=(typename Container::const_reference value);
    <ins>back_insert_iterator&amp;
      operator=(typename Container::value_type&amp;&amp; value);</ins>

    back_insert_iterator<del>&lt;Container&gt;</del>&amp; operator*();
    back_insert_iterator<del>&lt;Container&gt;</del>&amp; operator++();
    back_insert_iterator<del>&lt;Container&gt;</del>  operator++(int);
  };
</pre></blockquote>

<h4><a name="24.4.2.2 - back_insert_iterator operations"></a>24.4.2.2 - <tt>back_insert_iterator</tt> operations</h4>
<h5><a name="24.4.2.2.2 - back_insert_iterator::operator_equals"></a>24.4.2.2.2 - <tt>back_insert_iterator::operator=</tt></h5>

<blockquote><pre>
back_insert_iterator<del>&lt;Container&gt;</del>&amp;
  operator=(typename Container::const_reference value);
</pre></blockquote>

<p>
-1- <b>Effects:</b>
<tt>container-&gt;push_back(value);</tt>
</p>

<p>
-2- <b>Returns:</b>
<tt>*this</tt>.
</p>

<blockquote><pre><ins>
back_insert_iterator&amp;
  operator=(typename Container::value_type&amp;&amp; value);
</ins></pre></blockquote>

<p><ins>
-3- <b>Effects:</b>
<tt>container-&gt;push_back(std::move(value));</tt>
</ins></p>

<p><ins>
-4- <b>Returns:</b>
<tt>*this</tt>.
</ins></p>

<h4><a name="24.4.2.3 - Class template front_insert_iterator"></a>24.4.2.3 - Class template <tt>front_insert_iterator</tt></h4>

<blockquote><pre>
  template &lt;class Container&gt;
  class front_insert_iterator :
        public iterator&lt;output_iterator_tag,void,void,void,void&gt; {
  protected:
    Container* container;

  public:
    typedef Container container_type;
    explicit front_insert_iterator(Container&amp; x);
    front_insert_iterator<del>&lt;Container&gt;</del>&amp;
      operator=(typename Container::const_reference value);
    <ins>front_insert_iterator&amp;
      operator=(typename Container::value_type&amp;&amp; value);</ins>

    front_insert_iterator<del>&lt;Container&gt;</del>&amp; operator*();
    front_insert_iterator<del>&lt;Container&gt;</del>&amp; operator++();
    front_insert_iterator<del>&lt;Container&gt;</del>  operator++(int);
  };
</pre></blockquote>

<h4><a name="24.4.2.4 - front_insert_iterator operations"></a>24.4.2.4 - <tt>front_insert_iterator</tt> operations</h4>
<h5><a name="24.4.2.4.2 - front_insert_iterator::operator_equals"></a>24.4.2.4.2 - <tt>front_insert_iterator::operator=</tt></h5>

<blockquote><pre>
front_insert_iterator<del>&lt;Container&gt;</del>&amp;
  operator=(typename Container::const_reference value);
</pre></blockquote>

<p>
-1- <b>Effects:</b>
<tt>container-&gt;push_front(value);</tt>
</p>

<p>
-2- <b>Returns:</b>
<tt>*this</tt>.
</p>

<blockquote><pre><ins>
front_insert_iterator&amp;
  operator=(typename Container::value_type&amp;&amp; value);
</ins></pre></blockquote>

<p><ins>
-3- <b>Effects:</b>
<tt>container-&gt;push_front(std::move(value));</tt>
</ins></p>

<p><ins>
-4- <b>Returns:</b>
<tt>*this</tt>.
</ins></p>

<h4><a name="24.4.2.5 - Class template insert_iterator"></a>24.4.2.5 - Class template <tt>insert_iterator</tt></h4>

<blockquote><pre>
  template &lt;class Container&gt;
  class insert_iterator :
        public iterator&lt;output_iterator_tag,void,void,void,void&gt; {
  protected:
    Container* container;
    typename Container::iterator iter;

  public:
    typedef Container container_type;
    insert_iterator(Container&amp; x, typename Container::iterator i);
    insert_iterator<del>&lt;Container&gt;</del>&amp;
      operator=(typename Container::const_reference value);
    <ins>insert_iterator&amp;
      operator=(typename Container::value_type&amp;&amp; value);</ins>

    insert_iterator<del>&lt;Container&gt;</del>&amp; operator*();
    insert_iterator<del>&lt;Container&gt;</del>&amp; operator++();
    insert_iterator<del>&lt;Container&gt;</del>&amp; operator++(int);
  };
</pre></blockquote>

<h4><a name="24.4.2.6 - insert_iterator operations"></a>24.4.2.6 - <tt>insert_iterator</tt> operations</h4>
<h5><a name="24.4.2.6.2 - insert_iterator::operator_equals"></a>24.4.2.6.2 - <tt>insert_iterator::operator=</tt></h5>

<blockquote><pre>
insert_iterator<del>&lt;Container&gt;</del>&amp;
  operator=(typename Container::const_reference value);
</pre></blockquote>

<p>
-1- <b>Effects:</b>
</p>

<blockquote><pre>
  iter = container-&gt;insert(iter, value);
  ++iter;
</pre></blockquote>

<p>
-2- <b>Returns:</b>
<tt>*this</tt>.
</p>

<blockquote><pre><ins>
insert_iterator&amp;
  operator=(typename Container::value_type&amp;&amp; value);
</ins></pre></blockquote>

<p><ins>
-3- <b>Effects:</b>
</ins></p>

<blockquote><pre><ins>
  iter = container-&gt;insert(iter, std::move(value));
  ++iter;
</ins></pre></blockquote>

<p><ins>
-4- <b>Returns:</b>
<tt>*this</tt>.
</ins></p>

<h3><a name="24.4.3 - Class template move_iterator"></a><ins>24.4.3 - Class template <tt>move_iterator</tt></ins></h3>

<blockquote class="note">
<p>
24.4.3 is a new section to be inserted.  The entire section is not marked in
<ins>yellow</ins> in an attempt to make it more readable. </p>
</blockquote>

<p>
-1- Class template <tt>move_iterator</tt> is an iterator adaptor that mimics the
underlying base iterator except that on dereference, the result of dereferencing
the underlying iterator is implicitly cast to an rvalue reference.  This can be
used to transform existing generic code which assumes copy semantics, into an
algorithm that moves from the source instead of copies from the source.
</p>

<p>
-2- [<i>Example:</i>
</p>

<blockquote><pre>
set&lt;string&gt; s;
...
vector&lt;string&gt; v1(s.begin(), s.end());           // strings copied into v1
vector&lt;string&gt; v2(make_move_iterator(s.begin()),
                  make_move_iterator(s.end()));  // strings <em>moved</em> into v2
</pre></blockquote>

<p>
<i>-- end example</i>]
</p>

<blockquote><pre>
namespace std {
  template &lt;class Iterator&gt;
  class move_iterator
  {
  public:
      typedef Iterator                                              iterator_type;
      typedef typename iterator_traits&lt;Iterator&gt;::difference_type   difference_type;
      typedef typename iterator_traits&lt;Iterator&gt;::pointer           pointer;
      typedef typename iterator_traits&lt;Iterator&gt;::value_type        value_type;
      typedef typename iterator_traits&lt;Iterator&gt;::iterator_category iterator_category;
      typedef value_type&&                                          reference;

      move_iterator();
      explicit move_iterator(iterator_type i);
      template &lt;class U&gt; move_iterator(const move_iterator&lt;U&gt;& u);
      template &lt;class U&gt; move_iterator&amp; operator=(const move_iterator&lt;U&gt;& u);

      iterator_type base() const;
      reference operator*() const;
      pointer   operator-&gt;() const;

      move_iterator& operator++();
      move_iterator  operator++(int);
      move_iterator& operator--();
      move_iterator  operator--(int);

      move_iterator  operator+ (difference_type n) const;
      move_iterator& operator+=(difference_type n);
      move_iterator  operator- (difference_type n) const;
      move_iterator& operator-=(difference_type n);
      reference operator[](difference_type n) const;
  };

  template &lt;class Iterator1, class Iterator2&gt;
  bool
  operator==(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);

  template &lt;class Iterator1, class Iterator2&gt;
  bool
  operator!=(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);

  template &lt;class Iterator1, class Iterator2&gt;
  bool
  operator&lt; (const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);

  template &lt;class Iterator1, class Iterator2&gt;
  bool
  operator&lt;=(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator&gt;& y);

  template &lt;class Iterator1, class Iterator2&gt;
  bool
  operator&gt; (const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);

  template &lt;class Iterator1, class Iterator2&gt;
  bool
  operator&gt;=(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);

  template &lt;class Iterator1, class Iterator2&gt;
  typename move_iterator&lt;Iterator&gt;::difference_type
  operator-(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);

  template &lt;class Iterator&gt;
  move_iterator&lt;Iterator&gt;
  operator+(typename move_iterator&lt;Iterator&gt;::difference_type n,
            const move_iterator&lt;Iterator&gt;& x);

  template &lt;class Iterator&gt;
  move_iterator&lt;Iterator&gt;
  make_move_iterator(const Iterator& i);

}
</pre></blockquote>

<h4><a name="24.4.3.1 - move_iterator requirements"></a>24.4.3.1 - <tt>move_iterator</tt> requirements</h4>

<p>
-1- The template parameter for <tt>move_iterator</tt> shall meet the
requirements for <tt>InputIterator</tt>.  Additionally if any of the
bidirectional or random access traversal functions are instantiated, the
template parameter must additionally meet the requirements of bidirectional or
random access iterator accordingly.
</p>

<h4><a name="24.4.3.2 - move_iterator operations"></a>24.4.3.2 - <tt>move_iterator</tt> operations</h4>
<h5><a name="24.4.3.2.1 - move_iterator constructors"></a>24.4.3.2.1 - <tt>move_iterator</tt> constructors</h5>

<blockquote><pre>
move_iterator();
</pre></blockquote>

<p>
-1- <b>Effects:</b> Default constructs the <tt>move_iterator</tt> by default
constructing the contained <tt>Iterator</tt>.
</p>

<blockquote><pre>
explicit move_iterator(iterator_type i);
</pre></blockquote>

<p>
-2- <b>Effects:</b> Constructs the <tt>move_iterator</tt> by copy constructing
the contained <tt>Iterator</tt> with <tt>i</tt>.
</p>

<blockquote><pre>
template &lt;class U&gt; move_iterator(const move_iterator&lt;U&gt;& u);
</pre></blockquote>

<p>
-3- <b>Effects:</b> Constructs the <tt>move_iterator</tt> by constructing
the contained <tt>Iterator</tt> with <tt>u.base()</tt>.
</p>

<p>
-4- <b>Requires:</b> <tt>U</tt> must be convertible to <tt>Iterator</tt>.
</p>

<h5><a name="24.4.3.2.2 - move_iterator assignment"></a>24.4.3.2.2 - <tt>move_iterator</tt> assignment</h5>

<blockquote><pre>
template &lt;class U&gt; move_iterator&amp; operator=(const move_iterator&lt;U&gt;& u);
</pre></blockquote>

<p>
-1- <b>Effects:</b> Assigns <tt>u.base()</tt> to the contained
<tt>Iterator</tt>.
</p>

<p>
-2- <b>Requires:</b> <tt>U</tt> must be convertible to <tt>Iterator</tt>.
</p>

<h5><a name="24.4.3.2.3 - move_iterator access"></a>24.4.3.2.3 - <tt>move_iterator</tt> access</h5>

<blockquote><pre>
iterator_type base() const;
</pre></blockquote>

<p>
-1- <b>Effects:</b> Returns the contained <tt>Iterator</tt>.
</p>

<blockquote><pre>
reference operator*() const;
</pre></blockquote>

<p>
-2- <b>Effects:</b> Returns the result of the dereferenced contained
<tt>Iterator</tt>, implicitly cast to an rvalue reference.
</p>

<blockquote><pre>
pointer operator-&gt;() const;
</pre></blockquote>

<p>
-3- <b>Effects:</b> Returns the contained <tt>Iterator</tt>.
</p>

<h5><a name="24.4.3.2.4 - move_iterator traversal"></a>24.4.3.2.4 - <tt>move_iterator</tt> traversal</h5>

<blockquote><pre>
move_iterator& operator++();
</pre></blockquote>

<p>
-1- <b>Effects:</b> Increments the contained <tt>Iterator</tt>.
</p>

<p>
-2- <b>Returns:</b> <tt>*this</tt>.
</p>

<blockquote><pre>
move_iterator operator++(int);
</pre></blockquote>

<p>
-3- <b>Effects:</b> Increments the contained <tt>Iterator</tt>.
</p>

<p>
-4- <b>Returns:</b> A copy of <tt>*this</tt> prior to the increment.
</p>

<blockquote><pre>
move_iterator& operator--();
</pre></blockquote>

<p>
-5- <b>Effects:</b> Decrements the contained <tt>Iterator</tt>.
</p>

<p>
-6- <b>Returns:</b> <tt>*this</tt>.
</p>

<blockquote><pre>
move_iterator operator--(int);
</pre></blockquote>

<p>
-7- <b>Effects:</b> Decrements the contained <tt>Iterator</tt>.
</p>

<p>
-8- <b>Returns:</b> A copy of <tt>*this</tt> prior to the decrement.
</p>

<blockquote><pre>
move_iterator operator+ (difference_type n) const;
</pre></blockquote>

<p>
-9- <b>Effects:</b> Adds <tt>n</tt> to a copy of the contained
<tt>Iterator</tt>.
</p>

<p>
-10- <b>Returns:</b> The copy of the returned <tt>Iterator</tt> which had
<tt>n</tt> added to it.
</p>

<blockquote><pre>
move_iterator& operator+=(difference_type n);
</pre></blockquote>

<p>
-11- <b>Effects:</b> Adds <tt>n</tt> to the contained <tt>Iterator</tt>.
</p>

<p>
-12- <b>Returns:</b> <tt>*this</tt>.
</p>

<blockquote><pre>
move_iterator operator- (difference_type n) const;
</pre></blockquote>

<p>
-13- <b>Effects:</b> Subtracts <tt>n</tt> from a copy of the contained
<tt>Iterator</tt>.
</p>

<p>
-14- <b>Returns:</b> The copy of the returned <tt>Iterator</tt> which had
<tt>n</tt> subtracted from it.
</p>

<blockquote><pre>
move_iterator& operator-=(difference_type n);
</pre></blockquote>

<p>
-15- <b>Effects:</b> Subtracts <tt>n</tt> from the contained <tt>Iterator</tt>.
</p>

<p>
-16- <b>Returns:</b> <tt>*this</tt>.
</p>

<blockquote><pre>
reference operator[](difference_type n) const;
</pre></blockquote>

<p>
-17- <b>Effects:</b> Applies <tt>n</tt> to the contained <tt>Iterator</tt> using
the index operator.
</p>

<p>
-18- <b>Returns:</b> The result of <tt>n</tt> applied to the contained
<tt>Iterator</tt> using the index operator, implicitly cast to an rvalue
reference.
</p>

<blockquote><pre>
template &lt;class Iterator1, class Iterator2&gt;
typename move_iterator&lt;Iterator&gt;::difference_type
operator-(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);
</pre></blockquote>

<p>
-19- <b>Returns:</b> <tt>x.base() - y.base()</tt>.
</p>

<blockquote><pre>
template &lt;class Iterator&gt;
move_iterator&lt;Iterator&gt;
operator+(typename move_iterator&lt;Iterator&gt;::difference_type n,
          const move_iterator&lt;Iterator&gt;& x);
</pre></blockquote>

<p>
-20- <b>Returns:</b> <tt>move_iterator&lt;Iterator&gt;(x.base() + n)</tt>.
</p>

<h5><a name="24.4.3.2.5 - move_iterator comparison"></a>24.4.3.2.5 - <tt>move_iterator</tt> comparison</h5>

<blockquote><pre>
template &lt;class Iterator1, class Iterator2&gt;
bool
operator==(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);
</pre></blockquote>

<p>
-1- <b>Returns:</b> <tt>x.base() == y.base()</tt>.
</p>

<blockquote><pre>
template &lt;class Iterator1, class Iterator2&gt;
bool
operator!=(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);
</pre></blockquote>

<p>
-2- <b>Returns:</b> <tt>!(x == y)</tt>.
</p>

<blockquote><pre>
template &lt;class Iterator1, class Iterator2&gt;
bool
operator&lt; (const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);
</pre></blockquote>

<p>
-3- <b>Returns:</b> <tt>x.base() &lt; y.base()</tt>.
</p>

<blockquote><pre>
template &lt;class Iterator1, class Iterator2&gt;
bool
operator&lt;=(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);
</pre></blockquote>

<p>
-4- <b>Returns:</b> <tt>!(y &lt; x)</tt>.
</p>

<blockquote><pre>
template &lt;class Iterator1, class Iterator2&gt;
bool
operator&gt; (const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);
</pre></blockquote>

<p>
-5- <b>Returns:</b> <tt>y &lt; x</tt>.
</p>

<blockquote><pre>
template &lt;class Iterator1, class Iterator2&gt;
bool
operator&gt;=(const move_iterator&lt;Iterator1&gt;& x, const move_iterator&lt;Iterator2&gt;& y);
</pre></blockquote>

<p>
-6- <b>Returns:</b> <tt>!(x &lt; y)</tt>.
</p>

<h5><a name="24.4.3.2.6 - make_move_iterator"></a>24.4.3.2.6 - <tt>make_move_iterator</tt></h5>

<blockquote><pre>
template &lt;class Iterator&gt;
move_iterator&lt;Iterator&gt;
make_move_iterator(const Iterator& i);
</pre></blockquote>

<p>
-1- <b>Returns:</b> <tt>move_iterator&lt;Iterator&gt;(i)</tt>.
</p>

</body>
</html>
