473,406 Members | 2,352 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 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 2948
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Thomas J. Clancy | last post by:
I was wondering if anyone knew of a way to use std::copy() and istream_iterator<>/ostream_iterator<> write a file copy function that is quick and efficient. Doing this messes up the file because...
30
by: franky.backeljauw | last post by:
Hello, I am wondering which of these two methods is the fastest: std::copy, which is included in the standard library, or a manually written pointer copy? Do any of you have any experience with...
3
by: kathy | last post by:
I have array: double a; double b; std::vector <double> vDouble; when I use: std::copy(a,a+1024,vDouble.begin());
1
by: Siegfried Heintze | last post by:
What is the minimum I must type to create a custom iterator that will allow me display my iterator on std::cout using std::copy? Thanks, Siegfried
1
by: Siegfried Heintze | last post by:
Should the following work? It does on some compilers. How can I get it to work on g++ 3.2? On g++ 3.2 it keeps telling me that there is no such function operator << for ostream and...
6
by: Chris Johnson | last post by:
Greetings all. I am really stuck on this one as I can't seem to grok if I am abusing the C++ language or if I am simply using components of the C++ Standard Library incorrectly. Here is the code:...
5
by: Pradeep | last post by:
Hi All, I am facing some problem using istream_iterator for reading the contents of a file and copying it in a vector of strings.However the same thing works for a vector of integers. The...
3
by: none | last post by:
Hi, Consider the following piece of code: int t={1,2,3,4,5,6}; vector<intv; std::copy (t, t+sizeof(t)/sizeof(t), std::back_inserter (v)); Could someone explain me why we can pass "t" as an...
9
by: arnuld | last post by:
Earlier, I have posted a program like this, a month ago IIRC. I have created it again, without looking at the old program. Can I have your opinions on this: 1) I wanted my program to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.