public member function
<iterator>

std::move_iterator::operator=

template <class Iter>  move_iterator& operator= (const move_iterator<Iter>& m_it);
Assign iterator
Assigns m_it's base iterator to the object's base iterator, replacing its current value.

Parameters

m_it
An iterator of a move_iterator type, whose base iterator is copied.
Iter shall be a type convertible to the type of the base iterator.

Return value

*this

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// move_iterator::operator= example
#include <iostream>     // std::cout
#include <iterator>     // std::move_iterator
#include <vector>       // std::vector
#include <string>       // std::string
#include <algorithm>    // std::copy

int main () {
  std::vector<std::string> foo (3);
  std::vector<std::string> bar {"one","two","three"};

  std::move_iterator<std::vector<std::string>::iterator> from,until;

  // move_iterator assignments:
  from = bar.begin();
  until = bar.end();

  std::copy ( from, until, foo.begin() );

  // bar contains unspecified values; clear it:
  bar.clear();

  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 the copy-assignment of the base iterator.

See also