reverse_iterator::operator++
Incrementa o reverse_iterator ao elemento anterior.
reverse_iterator<RandomIterator>& operator++( );
reverse_iterator<RandomIterator> operator++( int );
Valor de retorno
O primeiro operador retornará reverse_iterator preincremented e o segundo, um operador de postincrement, retorna uma cópia de reverse_iteratorincrementado.
Comentários
Essa função de membro pode ser usada apenas se reverse_iterator satisfaz os requisitos para um iterador bidirecional.
Exemplo
// reverse_iterator_op_incr.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <iostream>
int main( )
{
using namespace std;
int i;
vector<int> vec;
for ( i = 1 ; i < 6 ; ++i )
{
vec.push_back ( 2 * i - 1 );
}
vector <int>::iterator vIter;
cout << "The vector vec is: ( ";
for ( vIter = vec.begin( ) ; vIter != vec.end( ); vIter++)
cout << *vIter << " ";
cout << ")." << endl;
vector <int>::reverse_iterator rvIter;
cout << "The vector vec reversed is: ( ";
for ( rvIter = vec.rbegin( ) ; rvIter != vec.rend( ); rvIter++)
cout << *rvIter << " ";
cout << ")." << endl;
// Initializing reverse_iterators to the last element
vector <int>::reverse_iterator rVPOS1 = vec.rbegin( );
cout << "The iterator rVPOS1 initially points to the first "
<< "element\n in the reversed sequence: "
<< *rVPOS1 << "." << endl;
rVPOS1++; // postincrement, preincrement: ++rVPSO1
cout << "After incrementing, the iterator rVPOS1 points\n"
<< " to the second element in the reversed sequence: "
<< *rVPOS1 << "." << endl;
}
Requisitos
Cabeçalho: <iterator>
Namespace: std