Inserts the given value value
to the container.
iter = container->insert(iter, value); ++iter;
iter = container->insert(iter, std::move(value)); ++iter;
value | - | the value to insert |
*this
.
This function exploits the signature compatibility between hinted insert for associative containers (such as std::set::insert
) and positional insert for sequential containers (such as std::vector::insert
).
#include <iostream> #include <iterator> #include <deque> int main() { std::deque<int> q; std::insert_iterator< std::deque<int> > it(q, q.begin()); for (int i=0; i<10; ++i) it = i; // inserts i for (auto& elem : q) std::cout << elem << ' '; }
Output:
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/iterator/insert_iterator/operator%3D