public member function
<iterator>

std::move_iterator::operator++

(1)
move_iterator& operator++();
(2)
move_iterator  operator++(int);
Increment iterator position
Advances the iterator by one position.

Internally, the pre-increment version (1) simply reflects the operation into its base iterator .

The post-increment version (2) is implemented with a behavior equivalent to:
1
2
3
4
5
move_iterator operator++(int) {
  move_iterator temp = *this;
  ++(*this);
  return temp;
}

Parameters

none (the second version overloads the post-increment operator).

Return value

The pre-increment version (1) returns *this.
The post-increment version (2) returns the value *this had before the call.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// move_iterator::operator++ example
#include <iostream>     // std::cout
#include <iterator>     // std::move_iterator
#include <vector>       // std::vector
#include <string>       // std::string

int main () {
  std::string str[] = {"one","two","three"};
  std::vector<std::string> foo;

  std::move_iterator<std::string*> it (str);
  for (int i=0; i<3; ++i) {
    foo.push_back(*it);
    ++it;
  }

  std::cout << "foo:";
  for (std::string& x : foo) std::cout << ' ' << x;
  std::cout << '\n';

  return 0;
}

Output:

foo: one two three


Data races

Modifies the object.
The iterator returned can be used to access or modify pointed elements.

Exception safety

Provides the same level of guarantee as increasing (and copying, for (2)) the base iterator.

See also