472,805 Members | 914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

return result of "copy", "remove_copy"

Hello,

The C++ reference says the return result of "copy" is an output
iterator. I'm wondering how I can assign the returned iterator to
some other iterator. I tried

int main(){
string s("abcdefg");
vector<charv;
vector<char>::iterator k = copy(s.begin(),s.end(),back_inserter(v));
return 0;
}

because for "copy", the returned iterator should point to the last
element in the destination range. However, the code above couldn't
compile. What's my problem? Moreover, does "copy" return the iterator
pointing to the last element or one past the last element?

As for "remove_copy", does it return the iterator pointing to one past
the last element? How can I assign the return result to some
iterator? I think it should be the same as for "copy".

Thanks,
Jess

Jul 6 '07 #1
3 1876
On Jul 6, 10:51 am, Jess <w...@hotmail.comwrote:
Hello,

The C++ reference says the return result of "copy" is an output
iterator. I'm wondering how I can assign the returned iterator to
some other iterator. I tried

int main(){
string s("abcdefg");
vector<charv;
vector<char>::iterator k = copy(s.begin(),s.end(),back_inserter(v));
copy will return the back_insert_iterator

std::back_insert_iterator<std::vector<char k = copy(s.begin(),
s.end(), back_insertor(v));

Moreover, does "copy" return the iterator
pointing to the last element or one past the last element?
last element
>
As for "remove_copy", does it return the iterator pointing to one past
the last element?

no. last element.
How can I assign the return result to some
iterator? I think it should be the same as for "copy".
Yeah.
Thanks,
Jess

Jul 6 '07 #2
"Neelesh Bodas" <ne***********@gmail.comwrote in message
news:11**********************@a26g2000pre.googlegr oups.com...
> Moreover, does "copy" return the iterator
pointing to the last element or one past the last element?
last element
I think not. The typical implementation does something similar to this:

template<class In, class Out>
Out copy(In begin, In end, Out dest)
{
while (begin != end)
*out++ = *begin++;
return out;
}

so what it returns is an iterator referring to the point after the last
element of the result.
Jul 7 '07 #3
Thanks for the replies!
Jess

Jul 8 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chagh | last post by:
hi all, how can we have a select satement in an SP?(i want to return a result set from the SP). i want to migrate from SQL Server to MySQL and i donít know what to do with these SPs. it can be...
3
by: uthuras | last post by:
hi all, One of my customer having warehouse database running on DB2. Recently when they execute the following query at db2 command line the exepected result take ages before return result ...
0
by: Florian | last post by:
Hi Uthuras, it would be helpful to see the access path. However sometimes it makes sense to rewrite a "not in" to gain better access paths: I tried the following - hopefully similar -...
2
by: Lacka | last post by:
Hi, If I have a stored procedure in my database, that has two parameters (say @a nvarchar(50) and @b int), and returns the result of a SELECT statement (returns a result set), how can I set up...
7
by: Bernard Lebel | last post by:
Hello, I'm stumbled at a serious problem, and quite frankly getting desparate. This is a rather long-winded one so I'll try to get straight to the point. I have this Python program, that...
2
by: Steven | last post by:
Hello, In English version of Windows Vista, run a command (for example icacls.exe) as administrator from Command Prompt, i can determine if the command successfully executed base on the return...
7
by: Big Moxy | last post by:
Can someone please advise me on how to implement this? The data entered by a user on form 1 on page1.php is posted to delete.php to remove that row from a table. After the SQL operation the user...
1
by: CAG | last post by:
Hi, In my application, i'm storing sql query as value of table field in database. Like in my NewHireEmployee table, value of JoinDateQuery field can be (select hiredate from employeeInfo) or...
2
by: HowHow | last post by:
Using Access 2000, normally query returns result horizontally. Is there any way to set the query to return result vertically? For example, my query shown the result as below: Heading ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.