Joey Arnold Andres
Joey Arnold Andres

Reputation: 368

Insert Iterators vs container's member function inserter

I've been studying stl for the past two weeks and been dealing with alot of vector<T>, deque<T>, and list<T>. All those times I've been using push_back(), push_front(), insert(). Currently though, I've been introduced to "Insert Iterators" which are the following:

So I know how to implement all of this. My question is quite simple, what is the difference? Why bother using the Insert Iterators?

Upvotes: 3

Views: 357

Answers (1)

Stuart Golodetz
Stuart Golodetz

Reputation: 20616

Because you can pass them to algorithms, e.g.

std::copy(v1.begin(), v1.end(), std::back_inserter(v2));

Upvotes: 9

Related Questions