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

Discussion in 'C++' started by xmllmx, Jun 12, 2010.

  1. xmllmx

    xmllmx Guest

    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!
    xmllmx, Jun 12, 2010
    #1
    1. Advertising

  2. xmllmx

    Jonathan Lee Guest

    On Jun 11, 10:57 pm, xmllmx <> 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
    Jonathan Lee, Jun 12, 2010
    #2
    1. Advertising

  3. xmllmx

    xmllmx Guest

    On Jun 12, 11:36 am, Jonathan Lee <> wrote:
    > On Jun 11, 10:57 pm, xmllmx <> 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!
    xmllmx, Jun 12, 2010
    #3
  4. xmllmx

    Jorgen Grahn Guest

    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 .
    Jorgen Grahn, Jun 13, 2010
    #4
  5. Re: Does the C++ standard define the global function of " istream& operator >>(istream& in, string& str); "?

    Jorgen Grahn <> 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)?
    Juha Nieminen, Jun 13, 2010
    #5
  6. xmllmx

    Jorgen Grahn Guest

    On Sun, 2010-06-13, Juha Nieminen wrote:
    > Jorgen Grahn <> 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 .
    Jorgen Grahn, Jun 15, 2010
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David
    Replies:
    2
    Views:
    472
    Thomas G. Marshall
    Aug 3, 2003
  2. Trevor

    sizeof(str) or sizeof(str) - 1 ?

    Trevor, Apr 3, 2004, in forum: C Programming
    Replies:
    9
    Views:
    626
    CBFalconer
    Apr 10, 2004
  3. Sullivan WxPyQtKinter

    It is fun.the result of str.lower(str())

    Sullivan WxPyQtKinter, Mar 7, 2006, in forum: Python
    Replies:
    5
    Views:
    335
    Tim Roberts
    Mar 9, 2006
  4. Stefan Ram

    str.equals(null) or str==null ?

    Stefan Ram, Jul 31, 2006, in forum: Java
    Replies:
    21
    Views:
    14,688
    Oliver Wong
    Aug 3, 2006
  5. robin liu
    Replies:
    3
    Views:
    821
    Robin Liu
    Apr 21, 2006
Loading...

Share This Page