public member function
<ios> <iostream>

std::ios::operator!

bool operator!() const;
Evaluate stream (not)
Returns true if either failbit or badbit is set, and false otherwise.

This is equivalent to calling member fail.

Parameters

none

Return Value

true if either failbit or badbit is set.
false otherwise.

Example

1
2
3
4
5
6
7
8
9
10
11
// evaluating a stream (not)
#include <iostream>     // std::cout
#include <fstream>      // std::ifstream

int main () {
  std::ifstream is;
  is.open ("test.txt");
  if (!is)
    std::cerr << "Error opening 'test.txt'\n";
  return 0;
}


Data races

Accesses the stream object.
Concurrent access to the same stream object may cause data races.

Exception safety

Strong guarantee: if an exception is thrown, there are no changes in the stream.

See also