Copy algorithm usage: 1) copy v2 to v1. 2) it use loop inside. Almostall uses of copy where the destination range is specified usingan insert iterator should be replaced with calls to rangemember function.
A good example to explain why use range member function is below: When
you use insert, inside of insert, STL will get distance(n elements) of
v2,begin() and v2.end(). Then , It will reserve and move the all element in
v1 just once according to the distance. If you use copy, it use loop insert
one by one, It will move all element in v1 n times. if no space, it
will reallocate and copy old element, just like common vector do.
So use range member function, can save you a lot of time in this
example.