public member function
<iterator>

std::move_iterator::operator++

(1)
move_iterator& operator++();
(2)
move_iterator  operator++(int);
前進迭代器位置
將迭代器向前移動一個位置。

內部,字首遞增版本(1)只是將其操作反映到其基迭代器

字尾遞增版本(2)的實現行為等同於
1
2
3
4
5
move_iterator operator++(int) {
  move_iterator temp = *this;
  ++(*this);
  return temp;
}

引數

無(第二個版本過載了字尾遞增運算子)。

返回值

字首遞增版本(1)返回*this
字尾遞增版本(2)返回呼叫前*this的值。

示例

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;
}

輸出

foo: one two three


資料競爭

修改物件。
返回的迭代器可用於訪問或修改指向的元素。

異常安全

提供的保證級別與增加(以及複製(2)基迭代器相同。

另見