How do I select a version of libstdc+ to link against?
Jonathan Wakely
jwakely.gcc@gmail.com
Thu Sep 22 11:10:00 GMT 2011
On 22 September 2011 11:58, Jonathan Wakely wrote:
>
> Anyway, the right way to write that loop is:
>
> while (iss>>std::boolalpha>>b)
> {
> myVect.push_back(b);
> }
And if you want to detect a failure to read a boolean (rather than
simply EOF) follow the loop with:
if (!iss.eof())
cout << "fail" << endl;
That should give the same behaviour with 4.1 and 4.4 for your test,
and for the case where the stream fails because it contains a
non-boolean value such as "true true x" or "true true fal"
Testing !iss.eof() tells you that the loop exited for some reason
other than reaching EOF, i.e. it couldn't convert the input to bool.
More information about the Libstdc++
mailing list