insert_iterator::operator++
Increments the insert_iterator to the next location into which a value may be stored.
insert_iterator<Container>& operator++( );
insert_iterator<Container> operator++( int );
매개 변수
A insert_iterator addressing the next location into which a value may be stored.
설명
Both preincrementation and postincrementation operators return the same result.
예제
// insert_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 < 5 ; ++i )
{
vec.push_back ( i );
}
vector <int>::iterator vIter;
cout << "The vector vec is:\n ( ";
for ( vIter = vec.begin ( ) ; vIter != vec.end ( ); vIter++ )
cout << *vIter << " ";
cout << ")." << endl;
insert_iterator<vector<int> > ii ( vec, vec.begin ( ) );
*ii = 30;
ii++;
*ii = 40;
ii++;
*ii = 50;
cout << "After the insertions, the vector vec becomes:\n ( ";
for ( vIter = vec.begin ( ) ; vIter != vec.end ( ); vIter++ )
cout << *vIter << " ";
cout << ")." << endl;
}
요구 사항
헤더: <iterator>
네임스페이스: std