473,666 Members | 2,111 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

copy an istringstream

/*Copy the line a token at a time into the output*/
copy(istream_it erator<string>( iss),
istream_iterato r<string>(),
ostream_iterato r<string>(oss, " "));

What's the meaning of this statement? Thanks!

Jul 22 '05 #1
14 2097

"dover" <do*****@close. com> wrote in message
news:g1******** *************@b gtnsc04-news.ops.worldn et.att.net...
/*Copy the line a token at a time into the output*/
copy(istream_it erator<string>( iss),
istream_iterato r<string>(),
ostream_iterato r<string>(oss, " "));

What's the meaning of this statement? Thanks!


Again as your previous post the comment gives you the answer. copy algorithm
takes three parameters - the first two are beginning and one past the end
iterators of the source range and the third parameter is the beginning
iterator of the destination range.
So your source range is a istringstream (strings can behave as external
devices to streams.) Your destination is an ostringstream with space as the
delimiter.
So if input stream contains "This is a test" then destination string will
also contain "This is a test".

-Sharad
Jul 22 '05 #2
dover wrote:
/*Copy the line a token at a time into the output*/
copy(istream_it erator<string>( iss),
istream_iterato r<string>(),
ostream_iterato r<string>(oss, " "));

What's the meaning of this statement? Thanks!


It copies the line a token at a time into the output.

Jul 22 '05 #3
dover wrote:
/*Copy the line a token at a time into the output*/
copy(istream_it erator<string>( iss),
istream_iterato r<string>(),
ostream_iterato r<string>(oss, " "));

What's the meaning of this statement? Thanks!


Others have answered this question. I'd like to pose a bonus question
to the group: what's the meaning of this statement?

vector<string> vec( istream_iterato r<string>(iss) ,
istream_iterato r<string>() );

--
Russell Hanneken
eu*******@cbobk .pbz
Use ROT13 to decode my email address.
Jul 22 '05 #4

"Russell Hanneken" <me@privacy.net > wrote in message
news:_j******** *********@newsr ead2.news.pas.e arthlink.net...
dover wrote:
/*Copy the line a token at a time into the output*/
copy(istream_it erator<string>( iss),
istream_iterato r<string>(),
ostream_iterato r<string>(oss, " "));

What's the meaning of this statement? Thanks!


Others have answered this question. I'd like to pose a bonus question
to the group: what's the meaning of this statement?

vector<string> vec( istream_iterato r<string>(iss) ,
istream_iterato r<string>() );


C++'s most vexing parse! It's a function declaration and not that of a
vector. To get correct results put another set of parenthesis -
vector<string> vec( (istream_iterat or<string>(iss) ),
istream_iterato r<string>() );

Seems you have read Effective STL ;-)

-Sharad

Jul 22 '05 #5

"Russell Hanneken" <me@privacy.net > wrote in message
news:_j******** *********@newsr ead2.news.pas.e arthlink.net...
dover wrote:
/*Copy the line a token at a time into the output*/
copy(istream_it erator<string>( iss),
istream_iterato r<string>(),
ostream_iterato r<string>(oss, " "));

What's the meaning of this statement? Thanks!


Others have answered this question. I'd like to pose a bonus question
to the group: what's the meaning of this statement?

vector<string> vec( istream_iterato r<string>(iss) ,
istream_iterato r<string>() );


C++'s most vexing parse! It's a function declaration and not that of a
vector. To get correct results put another set of parenthesis -
vector<string> vec( (istream_iterat or<string>(iss) ),
istream_iterato r<string>() );

Seems you have read Effective STL ;-)

-Sharad

Jul 22 '05 #6
Sharad Kala wrote:
"Russell Hanneken" <me@privacy.net > wrote in message
news:_j******** *********@newsr ead2.news.pas.e arthlink.net...
I'd like to pose a bonus question
to the group: what's the meaning of this statement?

vector<string> vec( istream_iterato r<string>(iss) ,
istream_iterato r<string>() );


C++'s most vexing parse! It's a function declaration and not that of a
vector. To get correct results put another set of parenthesis -
vector<string> vec( (istream_iterat or<string>(iss) ),
istream_iterato r<string>() );

Seems you have read Effective STL ;-)


Aw, you got it right. That's no fun. :^)

I haven't actually read _Effective STL_, but I did read "Guru of the
Week" #75, which covers the issue:

http://www.gotw.ca/gotw/075.htm

If anyone's confused about why the statement above declares a function
rather than a vector, I recommend the article.

--
Russell Hanneken
eu*******@cbobk .pbz
Use ROT13 to decode my email address.
Jul 22 '05 #7

"Sharad Kala" <no************ ******@yahoo.co m> wrote in message news:2l******** ****@uni-berlin.de...

"Russell Hanneken" <me@privacy.net > wrote in message
news:_j******** *********@newsr ead2.news.pas.e arthlink.net...
dover wrote:
/*Copy the line a token at a time into the output*/
copy(istream_it erator<string>( iss),
istream_iterato r<string>(),
ostream_iterato r<string>(oss, " "));

What's the meaning of this statement? Thanks!
Others have answered this question. I'd like to pose a bonus question
to the group: what's the meaning of this statement?

vector<string> vec( istream_iterato r<string>(iss) ,
istream_iterato r<string>() );


C++'s most vexing parse! It's a function declaration and not that of a vector.


Is it really a function _declaration_? : iss is not type, but variable (istringstream iss).
To get correct results put another set of parenthesis -
vector<string> vec( (istream_iterat or<string>(iss) ),
istream_iterato r<string>() );

[snip]
--
Alex Vinokur
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Jul 22 '05 #8

"Alex Vinokur" <al****@big.foo t.com> wrote in message
news:2l******** ****@uni-berlin.de...

"Sharad Kala" <no************ ******@yahoo.co m> wrote in message news:2l******** ****@uni-berlin.de...

"Russell Hanneken" <me@privacy.net > wrote in message
news:_j******** *********@newsr ead2.news.pas.e arthlink.net...

Is it really a function _declaration_? : iss is not type, but variable

(istringstream iss).

Yes, it is.

void foo( int d);
void foo (int (d)); // same as above; parens around d are ignored

With this knowledge, in vector<string> vec( istream_iterato r<string>(iss) ,
istream_iterato r<string>() );
the first parameter is of type istream_iterato r<string>. The parentheses
around iss are superfluous and are ignored. I hope you have got the second
parameter right by yourself :-)

-Sharad
Jul 22 '05 #9

"Sharad Kala" <no************ ******@yahoo.co m> wrote in message news:2l******** ****@uni-berlin.de...
[snip]

void foo( int d);
void foo (int (d)); // same as above; parens around d are ignored
d is of int type

With this knowledge, in vector<string> vec( istream_iterato r<string>(iss) ,
istream_iterato r<string>() );
the first parameter is of type istream_iterato r<string>. The parentheses
around iss are superfluous and are ignored.

[snip]

But iss is not of istream_iterato r<string> type; iss is of istringstream type.
--
Alex Vinokur
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn

Jul 22 '05 #10

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

Similar topics

1
3422
by: Samuele Armondi | last post by:
Hi everyone, Since istringstream objects are not assignable, I'm using the following code to allocate some dynamically. My question is: Is this the correct way of doing it? Am I deleting all the allocated memory correctly? Or am I missing something glaringly simple? Thanks in advance, S. Armondi std::istringstream** ArgStream;
8
5361
by: Agent Mulder | last post by:
I try to remove the spaces from a string using an old trick that involves an istringstream object. I expect the while-condition while(istringstream>>string) to evaluate to false once the istringstream is exhausted, but that is not the case. What am I missing? #include<iostream> #include<sstream> #include<string>
3
4732
by: bml | last post by:
Could you help and answer my questions of istringstream? Thanks a lot! 1. Reuse an "istringstream" istringstream ist; ist.str("This is FIRST test string"); ist.str("This is SECOND test string"); cout << ist.str() << endl;
7
748
by: Luther Baker | last post by:
Hi, My question is regarding std::istringstream. I am serializing data to an ostringstream and the resulting buffer turns out just fine. But, when I try the reverse, when the istringstream encounters the two byte shorts, it either thinks it has reached the null terminator? or eof and consequently stops reading values back in. It doesn't matter whether or not I use the std::ios::binary flag when opening the istringstream or the...
4
2323
by: dinks | last post by:
Hi I'm really new to c++ so please forgive me if this is really basic but im stuck... I am trying to make a data class that uses istringstram and overloaded << and >> operators to input and output data. The data comes in string lines like "OREBlegQ 14854 731.818" which need to be split into a string, int and double when stored in the class. Can anyone help? This is what i have so far: /* Begin Code */ #include <sstream>
8
2082
by: Randy Yates | last post by:
Why does this: string AWord(string& line) { return line; } bool MYOBJECT::MyFunction(string &line) { int day;
6
2987
by: James Aguilar | last post by:
Hello all, I am trying to use an istringstream to do some input off of cin by lines. The following snippet does not work: char buf; cin.getline(buf, 90); istringstream line1(string(buf));
13
11688
by: sakitah | last post by:
Hello Everyone, Here's the problem (I'm using Visual c++ 6.0): I have a string: string1 = "This&is&life";
7
3177
by: mathieu | last post by:
Hello, Is there a way to construct a std::istringstream from a buffer of char and avoid copying the array of bytes ? const char s = "Hello, World"; std::string str(s); std::istringstream is; is.str( str );
0
8448
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
8871
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8783
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...
0
7387
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
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
5666
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
4198
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...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.