This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
EOF after __copy_streambufs
- To: libstdc++ at gcc dot gnu dot org
- Subject: EOF after __copy_streambufs
- From: Brad Howes <howes at ll dot mit dot edu>
- Date: 09 Oct 2001 18:20:35 -0400
Is the EOF after copying streambufs from iss to cout valid (g++ 3.0.1)?
#include <iostream>
#include <strstream>
int
main( int argc, const char* argv[] )
{
const char* data = "first line # comment\n\
second line\n\
# commentary line\n\
last line\n";
std::istrstream iss( data );
std::cout << "Original:" << std::endl << iss.rdbuf();
short state = std::cout.rdstate();
std::cout.clear();
std::cout << "flags: " << std::hex << state << std::endl;
return 0;
}
When run, I get:
Original:
first line # comment
second line
# commentary line
last line
flags: 2
which is indicates that cout's ios::eofbit was set. It gets set by the
__copy_streambufs template function in streambuf.tcc. When the above code is
compiled under Sun's Forte v5, the eofbit does not get set. Which is correct?
Thanks,
Brad