This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How do I select a version of libstdc+ to link against?


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]