Failure to extract the value will set the "fail" bit of the stream, which can be detected using if (ss.fail()) or simply if (!ss) . Equivalently, you can check the result of the >> operation, as this returns a link to the stream.
They will also detect other errors that set the โbadโ bit; you can distinguish them from ss.bad() .
If you want to continue reading from the stream, you need to clear the status flags ( ss.clear() ).
source share