|
|
std::basic_ios::bad
is used when there is an unrecoverable error with the stream, std::basic_ios::fail
can be used to do what you want.isn't reading a string to an int an unrecoverable error? |
if(std::cin)
.This operator makes it possible to use streams and functions that return references to streams as loop conditions, resulting in the idiomatic C++ input loops such as while(stream >> value) {...} or while(getline(stream, string)){...}. Such loops execute the loop's body only if the input operation succeeded. |
|
|
|
|
|
|
|
|