Adaptors
Iterator adaptors enable the use of iterators in insert mode or with streams. They need the header <iterator>
.
Insert iterators
With the three insert iterators std::front_inserter, std::back_inserter
and std::inserter
you can insert an element into a container at the beginning, at the end or an arbitrary position respectively. The memory for the elements will automatically be provided. The three map their functionality on the underlying methods of the container cont
.
The table below gives you two pieces of information: Which methods of the containers are internally used and which iterators can be used depends on the container’s type.
Name | internally used method | Container |
---|---|---|
std::front_inserter(val) |
cont.push_front(val) |
std::deque |
std::list |
||
std::back_inserter(val) |
cont.push_back(val) |
std::vector |
...