函式
<ios> <iostream>

std::nounitbuf

ios_base& nounitbuf (ios_base& str);
不強制在插入後重新整理
清除 str 流的 unitbuf “格式”標誌。

unitbuf 標誌未設定時,關聯的緩衝區不會在每次插入操作後被強制重新整理。

此標誌可以透過 unitbuf 操縱符設定,強制在每次插入後進行重新整理。

對於標準流,unitbuf 標誌在初始化時未設定

引數

str
格式標誌受影響的流物件。
因為此函式是一個操縱符,它被設計為在不帶引數的情況下,與流上的插入 (<<) 和提取 (>>) 操作結合使用(見下例)。

返回值

引數 str

示例

1
2
3
4
5
6
7
8
9
10
// modify unifbuf flag
#include <ios>         // std::unitbuf
#include <fstream>     // std::ofstream

int main () {
  std::ofstream outfile ("test.txt");
  outfile << std::unitbuf <<  "Test " << "file" << '\n';  // flushed three times
  outfile.close();
  return 0;
}

資料競爭

修改 str。對同一個流物件的併發訪問可能導致資料競爭。

異常安全

基本保證:如果丟擲異常,str 處於有效狀態。

另見