Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

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

 
 
xmllmx
Guest
Posts: n/a
 
      06-12-2010
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!
 
Reply With Quote
 
 
 
 
Jonathan Lee
Guest
Posts: n/a
 
      06-12-2010
On Jun 11, 10:57*pm, xmllmx <(E-Mail Removed)> wrote:
> 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
 
Reply With Quote
 
 
 
 
xmllmx
Guest
Posts: n/a
 
      06-12-2010
On Jun 12, 11:36*am, Jonathan Lee <(E-Mail Removed)> wrote:
> On Jun 11, 10:57*pm, xmllmx <(E-Mail Removed)> wrote:
>
> > 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!
 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      06-13-2010
On Sat, 2010-06-12, xmllmx wrote:
> 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.

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
Juha Nieminen
Guest
Posts: n/a
 
      06-13-2010
Jorgen Grahn <(E-Mail Removed)> wrote:
> On Sat, 2010-06-12, xmllmx wrote:
>> 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)?
 
Reply With Quote
 
Jorgen Grahn
Guest
Posts: n/a
 
      06-15-2010
On Sun, 2010-06-13, Juha Nieminen wrote:
> Jorgen Grahn <(E-Mail Removed)> wrote:
>> On Sat, 2010-06-12, xmllmx wrote:
>>> 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

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
std::map, does the standard define what to do here? Zachary Turner C++ 6 04-08-2009 09:04 AM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 1 10-25-2006 06:50 PM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 0 10-25-2006 01:04 PM
About typedef -- define the function pointer or define function model? robin liu C Programming 3 04-21-2006 03:26 PM
global typedefs and #define /\ global inheritance base eiji C++ 5 12-06-2005 12:19 AM



Advertisments