front_insert_iterator
namespace opentl {
template <typename Container>
class front_insert_iterator;
}
An output iterator that prepends elements to a container.
Declared in <iterator/front_insert_iterator.hpp>.
Template Parameters
| Name |
Description |
Container |
The container type. |
Member Types
| Type |
Description |
container_type |
The container type. |
value_type |
The value type. |
difference_type |
The difference type. |
pointer |
The pointer type, output iterators are not dereferenceable to a pointer. |
reference |
The reference type, output iterators are not dereferenceable to a value. |
iterator_category |
The iterator category. |
Member Functions
| Name |
Return Type |
Description |
front_insert_iterator(container_type) |
|
front_insert_iterator constructor. |
operator=(const value_type&) |
front_insert_iterator& |
Prepends a copy of the value to the container. |
operator=(value_type&&) |
front_insert_iterator& |
Prepends the value to the container. |
operator*() |
front_insert_iterator& |
Returns a reference to the iterator. |
operator++() |
front_insert_iterator& |
Returns a reference to the iterator. |
operator++(int) |
front_insert_iterator |
Returns a copy of the iterator. |
Non-member Functions
| Name |
Return Type |
Description |
front_inserter(container) |
front_insert_iterator<Container> |
Creates a front_insert_iterator that prepends to the container. |
Example
#include <opentl/iterator.hpp>
struct stack {
using value_type = int;
void push_front(const int&);
void push_front(int&&);
};
int main() {
stack values;
auto it = opentl::front_inserter(values);
*it = 1;
*it = 2;
}