public member function
<iterator>

std::reverse_iterator::operator=

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

The object uses the same iteration direction as rev_ir (which is already a reverse iterator).

Note that reverse iterators cannot be assigned non-reverse iterators directly (they can be constructed from them, though).

Parameters

rev_it
An iterator of a reverse_iterator type, whose sense of iteration is preserved.

Return value

*this

Example

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

int main () {
  std::vector<int> myvector {10,20,30,40,50};

  std::vector<int>::const_reverse_iterator from,until;

  // reverse_iterator assignments:
  from = myvector.rbegin();
  until = myvector.rend();

  std::cout << "reversed myvector:";
  while (from != until)
    std::cout << ' ' << *from++;
  std::cout << '\n';

  return 0;
}


Output:
reversed myvector: 50 40 30 20 10

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