reverse_iterator::operator--

Diminui o reverse_iterator ao elemento anterior.

reverse_iterator<RandomIterator>& operator--( );
reverse_iterator<RandomIterator> operator--( int );

Valor de retorno

O primeiro operador retorna reverse_iterator predecremented, e o segundo operador de postdecrement, retorna uma cópia de reverse_iteratordecrescido.

Comentários

Essa função de membro pode ser usada somente se reverse_iterator satisfaz os requisitos para um iterador bidirecional.

Exemplo

// reverse_iterator_op_decr.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 first element
   vector <int>::reverse_iterator rVPOS1 = vec.rend ( ) - 1;
   
   cout << "The iterator rVPOS1 initially points to the last "
        << "element\n in the reversed sequence: "
        << *rVPOS1 << "." << endl;
   rVPOS1--;  // postdecrement, predecrement: --rVPSO1

   cout << "After the decrement, the iterator rVPOS1 points\n"
        << " to the next-to-last element in the reversed sequence: "
        << *rVPOS1 << "." << endl;
}
  
  
  
  

Requisitos

Cabeçalho: <iterator>

namespace: STD

Consulte também

Referência

reverse_iterator Class

Standard Template Library