This is the mail archive of the
cygwin@cygwin.com
mailing list for the Cygwin project.
Issue with stringstream class
- From: Silqun Leung <SLeung at ansoft dot com>
- To: "'cygwin at cygwin dot com'" <cygwin at cygwin dot com>
- Date: Thu, 2 Jan 2003 13:29:22 -0500
- Subject: Issue with stringstream class
Hello,
I am having some difficulty with the stringstream class. Here is a
simple program I run:
#include <sstream>
#include <iostream>
#include <string>
int main(int argc, char* argv[])
{
std::string temp;
std::string stuff = "asdf asdf asdf asdf asdf"; std::stringstream a;
a << stuff.c_str();
std::cout << a.str() << std::endl;
a >> temp;
std::cout << a.str();
return 0;
}
The output when built with g++ is:
asdf asdf asdf asdf asdf
asdf asdf asdf asdf asdf
This is not what I expect when using the >> operator. I looked at the
stringstream class and do not see it overloading the >> operator and believe
that it should be inheriting from the same place as the ifstream class. When
I use the >> operator on a std::ifstream object, it is destructive, however
this does not appear to be the case for the stringstream object (which I
believe it should be). Using the same program with Visual C++ will yield
correct results (ie. an output of asdf asdf asdf asdf asdf asdf asdf asdf
asdf
Is this a bug in the implementation of the stringstream class?
Thanks,
Silqun
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/