public member function
<ios> <iostream>
std::basic_ios::operator boolexplicit operator bool() const;
Evaluate stream
Returns whether an error flag is set (either failbit or badbit).Notice that this function does not return the same as member good, but the opposite of member fail.
The function returns a null pointer if at least one of these error flags is set, and some other value otherwise.
The function returns false
if at least one of these error flags is set, and true
otherwise.
A
null pointerif at least one of
failbitor
badbitis set. Some other value otherwise.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// evaluating a stream
#include <iostream> // std::cerr
#include <fstream> // std::ifstream
int main () {
std::ifstream is;
is.open ("test.txt");
if (is) {
// read file
}
else {
std::cerr << "Error opening 'test.txt'\n";
}
return 0;
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4