reverse_iterator::operator+=
Reverse_iterator에서 지정 된 오프셋을 추가합니다.
reverse_iterator<RandomIterator>& operator+=(
difference_type _Off
);
매개 변수
- _Off
반복기를 증가 하 여 오프셋입니다.
반환 값
참조를 해결 하는 요소는 reverse_iterator.
예제
// reverse_iterator_op_addoff.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 );
}
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+=2; // addition of an offset
cout << "After the +2 offset, the iterator rVPOS1 now points\n"
<< " to the third element in the reversed sequence: "
<< *rVPOS1 << "." << endl;
}
요구 사항
헤더: <iterator>
네임 스페이스: std