Does the C++ standard define the global function of " istream&operator >>(istream& in, string& str);

X

xmllmx

Dear all,

Maybe you know, I am a huge fan of C++. I have a question to ask:

string str;
cin >> str;

The code fragment above is very common. I think the global function "
istream& operator >>(istream& in, string& str); " must be of course
defined by the C++ standard.

I looked up the newest C++ standard from the first page to the last
page; However, I got nothing.

Who can tell me where to find the definition in the C++ standard. It
will be highly appreciated if someone can refer me to the exact page
number.

Thanks in advance!
 
J

Jonathan Lee

The code fragment above is very common. I think the global function "
istream& operator >>(istream& in, string& str); " must be of course
defined by the C++ standard.

I looked up the newest C++ standard from the first page to the last
page; However, I got nothing.

Who can tell me where to find the definition in the C++ standard. It
will be highly appreciated if someone can refer me to the exact page
number.

In the 2003 standard, page 410, [lib.string.io] aka 21.3.7.9

Found it in the index:
operator>>
basic_string 410

--Jonathan
 
X

xmllmx

The code fragment above is very common. I think the global function "
istream& operator >>(istream& in, string& str); " must be of course
defined by the C++ standard.
I looked up the newest C++ standard from the first page to the last
page; However, I got nothing.
Who can tell me where to find the definition in the C++ standard. It
will be highly appreciated if someone can refer me to the exact page
number.

In the 2003 standard, page 410, [lib.string.io] aka 21.3.7.9

Found it in the index:
  operator>>
    basic_string   410

--Jonathan

Thank you very much for your right answer and quick response!
 
J

Jorgen Grahn

Dear all,

Maybe you know, I am a huge fan of C++. I have a question to ask:

string str;
cin >> str;

The code fragment above is very common.

Not sure about that. I've been using C++ for over ten years, and I
have never learned what that fragment means -- does it read a line, or
a word, and what's the definition of a word?[1] And yet I'm in the
minority who frequently does Unix text I/O rather than GUI stuff.
I'm more likely to do

string str;
getline(cin, str);

/Jorgen

[1] A rhetorical question. I know I can find out if needed.
 
J

Juha Nieminen

Jorgen Grahn said:
Dear all,

Maybe you know, I am a huge fan of C++. I have a question to ask:

string str;
cin >> str;

The code fragment above is very common.

Not sure about that. I've been using C++ for over ten years, and I
have never learned what that fragment means -- does it read a line, or
a word, and what's the definition of a word?[1] And yet I'm in the
minority who frequently does Unix text I/O rather than GUI stuff.

Can you refer to even one source which mentions operator>> with respect
to std::string and does not tell what it actually does (in other words,
reads a whitespace-delimited group of characters from the input stream
to the string)?
 
J

Jorgen Grahn

Jorgen Grahn said:
Dear all,

Maybe you know, I am a huge fan of C++. I have a question to ask:

string str;
cin >> str;

The code fragment above is very common.

Not sure about that. I've been using C++ for over ten years, and I
have never learned what that fragment means -- does it read a line, or
a word, and what's the definition of a word?[1] And yet I'm in the
minority who frequently does Unix text I/O rather than GUI stuff.

Can you refer to even one source which mentions operator>> with respect
to std::string and does not tell what it actually does (in other words,
reads a whitespace-delimited group of characters from the input stream
to the string)?

You conveniently snipped this part of my posting:
[1] A rhetorical question. I know I can find out if needed.

I just stated this: that I never bothered to learn that particular
part of iostreams, that I never use it, and that I don't find it very
useful. (Maybe it doesn't even work for line-oriented input? I can't
say; see above).

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top