std::basic_ios<CharT,Traits>::operator bool
From cppreference.com
operator /* unspecified-boolean-type */() const;
|
(1) | (until C++11) |
explicit operator bool() const;
|
(2) | (since C++11) |
Checks whether the stream has no errors.
1) Returns a value that evaluates to
false in a boolean context if fail() returns true, otherwise returns a value that evaluates to true in a boolean context.2) Returns
true if the stream has no errors and is ready for I/O operations. Specifically, returns !fail(). 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 (std::getline(stream, string)) {...}. Such loops execute the loop's body only if the input operation succeeded.
Parameters
(none)
Return value
1) A value that evaluates to
true in a boolean context if the stream has no errors, a value that evaluates to