473,395 Members | 1,422 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,395 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 1927
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 ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...

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.