Partager via


front_insert_iterator::operator=

Appends (pushes) a value onto the front of the container.

front_insert_iterator<Container>& operator=(
   typename Container::const_reference _Val
);
front_insert_iterator<Container>& operator=(
   typename Container::value_type&& _Val
);

Parameters

  • _Val
    The value to be assigned to the container.

Return Value

A reference to the last element inserted at the front of the container.

Remarks

The first member operator evaluates container.push_front(_Val), then returns *this.

The second member operator evaluates

container->push_front((typename Container::value_type&&)_Val),

then returns *this.

Example

// front_insert_iterator_op_assign.cpp
// compile with: /EHsc
#include <iterator>
#include <list>
#include <iostream>

int main( )
{
   using namespace std;

   list<int> L1;
   front_insert_iterator<list<int> > iter ( L1 );
   *iter = 10;
   iter++;
   *iter = 20;
   iter++;
   *iter = 30;
   iter++;

   list <int>::iterator vIter;
   cout << "The list L1 is: ( ";
   for ( vIter = L1.begin ( ) ; vIter != L1.end ( ); vIter++ )
      cout << *vIter << " ";
   cout << ")." << endl;
}
The list L1 is: ( 30 20 10 ).

Requirements

Header: <iterator>

Namespace: std

See Also

Reference

front_insert_iterator Class

Standard Template Library

Other Resources

front_insert_iterator Members