Note: I have never needed to clone a container.
STL containers have 3 similar (confusing) operations. Target container ends up with exactly the same content as the source container. I consider them “cloning” operations, including swap.
1) generalized copy construction — from a source container to a new-born container
** I think you pass in a pair of iterators. [[c++Standard Lib Practical Tips]] P96 shows the list and vector constructors
2) assignment — from a source container to an Existing target container
** I think most containers offer an operator= and also a this->assign() method. [[c++Standard Lib Practical Tips]] P102 shows both.
[[ObjectSpace]] P14 covers operator=().
3) swap content — A ends up with B’s content, and B ends up with A’s content.
** Usually we use swap for one-way cloning. We clone from A to B and discard A.
** I think swap is a favorite among experts.
?) How about insert()? No. Insertion doesn’t meet the criteria in . However, I feel insertion is often more useful more versatile more consistent. See http://bigblog.tanbin.com/2012/05/versatile-technique-to-populate-1.html