Topic: cin and istream


Author: pmucci9443@my-dejanews.com
Date: 1999/05/03
Raw View
is the following legal ? assuming the standard C++ library is in use with
no extensions.

#include <iostream>
#include <string>

int main ()
  {
    std::string s;

    std::cout << "enter word" << std::endl;
    std::cin >> s;

    return 0;
  }

Yes, I know it is incredibly simple yet for some
reason I cannot find an overload for istream that takes
a basic_string, is it there and I am missing it ?

If its legal and it has to do with a subtle conversion
can you explain it.  After seeing an example on page 100 of CPPTPL
I am assuming its legal, I just want to know how ?

(btw, I had trouble with my news server so
if this results in multiple posts, I apologize)

- P Mucci


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: jpotter@falcon.lhup.edu (John Potter)
Date: 1999/05/03
Raw View
pmucci9443@my-dejanews.com wrote:

: is the following legal ? assuming the standard C++ library is in use with
: no extensions.

: #include <iostream>
: #include <string>

: int main ()
:   {
:     std::string s;

:     std::cout << "enter word" << std::endl;
:     std::cin >> s;

:     return 0;
:   }

: Yes, I know it is incredibly simple yet for some
: reason I cannot find an overload for istream that takes
: a basic_string, is it there and I am missing it ?

Yes.  The chapter on iostreams covers fundamental types and itself.
You may have noticed that the C string operators are not members
which makes some subtle differences.  You will find the string
operators as non-members in the chapter on strings.  The complex
operators ...

John
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]