471,071 Members | 1,202 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,071 software developers and data experts.

std::copy for overlapping ranges?

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
4 2768
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
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
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
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.

Similar topics

9 posts views Thread by Thomas J. Clancy | last post: by
30 posts views Thread by franky.backeljauw | last post: by
3 posts views Thread by kathy | last post: by
1 post views Thread by Siegfried Heintze | last post: by
1 post views Thread by Siegfried Heintze | last post: by
5 posts views Thread by Pradeep | last post: by
3 posts views Thread by none | last post: by
9 posts views Thread by arnuld | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.