By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,918 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,918 IT Pros & Developers. It's quick & easy.

std::copy for overlapping ranges?

P: n/a
Is there an equivalent of std::copy which works on STL containers for
overlapping ranges?

--
Simon Elliott http://www.ctsn.co.uk
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
In article <41***********************@news.gradwell.net>,
"Simon Elliott" <Simon at ctsn.co.uk> wrote:
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).

-Howard
Jul 23 '05 #2

P: n/a
On 01/02/2005, Howard Hinnant wrote:
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.

--
Simon Elliott http://www.ctsn.co.uk
Jul 23 '05 #3

P: n/a
On 2005-02-01 10:57:19 -0500, "Simon Elliott" <Simon at ctsn.co.uk> said:
On 01/02/2005, Howard Hinnant wrote:
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

--
Clark S. Cox, III
cl*******@gmail.com

Jul 23 '05 #4

P: n/a
On 01/02/2005, Clark S. Cox III wrote:

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


Thanks
--
Simon Elliott http://www.ctsn.co.uk
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.