468,777 Members | 2,285 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,777 developers. It's quick & easy.

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 2673
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
2 posts views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.