名前空間
変種
操作

std::basic_osyncstream<CharT,Traits,Allocator>::emit

提供: cppreference.com
 
 
入出力ライブラリ
入出力マニピュレータ
Cスタイルの入出力
バッファ
(C++98で非推奨)
ストリーム
抽象
ファイル入出力
文字列入出力
配列入出力
(C++98で非推奨)
(C++98で非推奨)
(C++98で非推奨)
同期化出力
エラーカテゴリインタフェース
(C++11)
 
 
void emit();

ベースとなる std::basic_syncbuf に対して emit() を呼ぶことによって、バッファされているすべての出力を排出し、あらゆる保留中のフラッシュを実行します。

[編集] 引数

(なし)

[編集]

#include <syncstream>
#include <iostream>
int main()
{
  {
    std::osyncstream bout(std::cout);
    std::bout << "Hello," << '\n'; // no flush
    std::bout.emit(); // characters transferred; cout not flushed
    std::bout << "World!" << std::endl; // flush noted; cout not flushed
    std::bout.emit(); // characters transferred; cout flushed
    std::bout << "Greetings." << '\n'; // no flush
  } // destructor calls emit(): characters transferred; cout not flushed
 
  // emit can be used for local exception-handling on the wrapped stream
  std::osyncstream bout(std::cout);
  bout << "Hello, " << "World!" << '\n';
  try {
    bout.emit();
  } catch (...) {
    // handle exceptions
  }
}

出力:

Hello,
World!
Greetings.
Hello, World!

[編集] 関連項目

basic_osyncstream を破棄し、その内部バッファを排出します
(パブリックメンバ関数) [edit]
内部バッファ全体をラップされた streambuf にアトミックに転送します
(std::basic_syncbuf<CharT,Traits,Allocator>のパブリックメンバ関数) [edit]