public member function
<ios> <iostream>

std::basic_ios::operator!

bool operator!() const;
求值流(非)
如果未設定錯誤標誌(failbitbadbit),則返回 true,否則返回 false

這等同於呼叫成員函式 fail

引數



返回值

如果設定了 failbitbadbit,則為 true
否則返回 false

示例

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;
}

資料競爭

訪問流物件。
併發訪問同一個流物件可能導致資料爭用。

異常安全

強保證: 如果丟擲異常,流不會發生任何改變。

另見