S
Simon Elliott
Is there an equivalent of std::copy which works on STL containers for
overlapping ranges?
overlapping ranges?
Simon Elliott said:Is there an equivalent of std::copy which works on STL containers for
overlapping ranges?
std::copy works for overlapping ranges as long as the destination is
earlier in the sequence than the source. Else you want
std::copy_backward. There is no std::algorithm which will make that
decision for you. You could write such an algorithm but it would be
limited to random access iterators, and would require that the source
and destination point into the same sequence (or that all of the
iterators be pointers).
Thanks for this, my STL docs are none too clear on this point.
For some pretty straightforward docs:
http://www.sgi.com/tech/stl/table_of_contents.html
Specifically, see the second footnote on the page:
http://www.sgi.com/tech/stl/copy.html#2
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.