Topic: section [21.3.7.9] of the Dec. '96 Draft
Author: Carley Williams <carley@heat.co.symbios.com>
Date: 1998/04/23 Raw View
My compiler vendor and i disagree over the behavior of the appended
code. I expect the stream extraction to fail setting both the eofbit and
failbit on the second "In1 >> str". The compiled code returns an empty
string in the "else".
I'm not sure i can make a case based on the wording in this section.
Maybe the failbit definition in 27.4.2.1.3 applies.
Can someone help? Is this clearer in the 11/97 standard?
--carley
#include <fstream>
#include <sstream>
using namespace std;
string buf(" a ");
main()
{
istringstream In1(buf);
string str;
In1 >> str;
// expect and get "a"
cerr << "\"" << str << "\"" << endl;
In1 >> str;
if (!In1)
{
// expect failbit and eofbit to be set
cerr << "fail" << endl;
}
else
{
// actually get an empty string here
cerr << "\"" << str << "\"" << endl;
}
}
--------------------------------------------
Carley D. Williams
Symbios Inc.
3351 Eastbrook Drive
Fort Collins, CO 80525
FAX: (970) 225-4829
PHONE: (970) 223-5100 x9421
EMAIL: Carley.Williams@symbios.com
--------------------------------------------
[ 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 ]