Just as std::coutif the stream is down (for some reason), the buffer state (eofbit, failbit or badbit) will be set. This will mean that operator bool()for the stream will be evaluated to false.
std::ostringstream oss;
if (!(oss << some_value))
{
}
Note. Prior to C ++ 11, this was accomplished with operator void*().
, , ( ), , std::ios::exceptions().