The container must have member push_front defined (such as standard containers deque and list).
Using the assignment operator on the front_insert_iterator, even when dereferenced, causes the container to insert a new element at its beginning. The other typical operators of an output iterator are also defined for front_insert_iterator but have no effect.
It is defined with an identical operation to:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
The library provides a function, called front_inserter, that automatically generates a front_insert_iterator class from a container.
Member functions
- constructor
- front_insert_iterator objects are constructed from a container.
- operator=
- Inserts a new element in the container, initializing its value to a copy of the argument.
- operator*
- Does nothing. Returns a reference to the object.
- operator++
- Does nothing. Returns a reference to the object.
Example
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
Output:
50 40 30 20 10 1 2 3 4 5 |
See also
| front_inserter | Constructs a front insert iterator (function template) |
| back_insert_iterator | Back insert iterator (class template) |
| insert_iterator | Insert iterator (class template) |
