473,856 Members | 1,714 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

return result of "copy", "remove_cop y"

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>::i terator k = copy(s.begin(), s.end(),back_in serter(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_cop y", 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 1979
On Jul 6, 10:51 am, Jess <w...@hotmail.c omwrote:
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>::i terator k = copy(s.begin(), s.end(),back_in serter(v));
copy will return the back_insert_ite rator

std::back_inser t_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_cop y", 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.goo glegroups.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
3050
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 done in MySQL client, but it gives the error:"procedure foo canít return a result set in the given context MySQL" in the application. can i set a cursor out put parameter and return it?(just like Oracle) or it has another solution?
3
4289
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 select count(*) from dss.fncsvcar where ar_id no in (select ar_id from dss.ar) Both tables ar_id is not a key field. However, indexes are created
0
2191
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 - statements in my environment. Watch the timerons of the different ways to get the same result set: Your Original:
2
1683
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 the parameters, how can I call it, and how can I iterate through the rows of the returned resultset? thanks, Lacka
7
3545
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 performs MySQL queries to a database. These queries are performed at regular intervals. Basically it is looking for fields that match certain criterias. Such fields are not present at all time. When the program finds such field, it then takes
2
1576
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 result, it is successful if the return result contained the string "successfully". But if Windows Vista is Non-English version, how to determine if the command has been executed successfully? Thank you
7
1961
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 is returned to page1.php. How can I determine the success or failure of the SQL operation so I can display an appropriate response message to the user? Thank you!
1
13438
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 simply (select getdate) I want to fetch this query, evaluate it and then return the result of query. I tried to write a function like this,
2
3410
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 below 70 70-74 75-79 80-84 85 and above Value returned 128 54 137 190 294 Is there any way to show the result as below?
0
9920
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9764
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10699
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10790
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7932
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 presenter, Adolph Duprť who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7098
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5762
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4176
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.