back_insert_iterator::operator++

增加 back_insert_iterator。值可以存储的位置。

back_insert_iterator<Container>& operator++( );
back_insert_iterator<Container> operator++( int );

返回值

解决值可以存储的位置的 back_insert_iterator

备注

preincrementation 和 postincrementation 运算符返回相同的结果。

示例

// back_insert_iterator_op_incre.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <iostream>

int main( )
{
   using namespace std;
   int i;

   vector<int> vec;
   for (i = 1 ; i < 3 ; ++i )  
   {
      vec.push_back ( 10 * i );
   }
   
   vector <int>::iterator vIter;
   cout << "The vector vec is: ( ";
   for ( vIter = vec.begin ( ) ; vIter != vec.end ( ); vIter++)
      cout << *vIter << " ";
   cout << ")." << endl;

   back_insert_iterator<vector<int> > backiter ( vec );
   *backiter = 30;
   backiter++;      // Increment to the next element
   *backiter = 40;
   backiter++;

   cout << "After the insertions, the vector vec becomes: ( ";
   for ( vIter = vec.begin ( ) ; vIter != vec.end ( ); vIter++)
      cout << *vIter << " ";
   cout << ")." << endl;
}
  

要求

头文件: <iterator>

命名空间: std

请参见

参考

back_insert_iterator 类

标准模板库