C++ IOS Library - operator


Advertisements

Description

It is used to check Evaluate stream (not). This is equivalent to calling member fail.

Declaration

Following is the declaration for ios::operator! function.

bool operator!() const;

Parameters

none

Return Value

True if either failbit or badbit is set or else false.

Exceptions

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

Data Races

Accesses the stream object.

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

Example

In below example explains about ios::operator! function.

#include <iostream>     
#include <fstream>      

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