reverse_iterator::operator--
감소 reverse_iterator 이전 요소.
reverse_iterator<RandomIterator>& operator--( );
reverse_iterator<RandomIterator> operator--( int );
반환 값
첫 번째 연산자는 predecremented 반환 reverse_iterator postdecrement 연산자, 두 번째는 감소의 복사본을 반환 하 고 reverse_iterator.
설명
이 멤버 함수의 경우만 사용할 수 있는 reverse_iterator 양방향 반복기에 대 한 요구 사항을 만족.
예제
// 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;
}
요구 사항
헤더: <iterator>
네임 스페이스: std