std::basic_osyncstream<CharT,Traits,Allocator>::emit
From cppreference.com
< cpp | io | basic osyncstream
| void emit(); |
||
バッファリングされたすべての出力を発行し、基となるstd::basic_syncbufに対してemit()を呼び出すことによって、保留中のフラッシュを実行します。
[編集] パラメータ
(なし)
[編集] 例
このコードを実行
#include <iostream> #include <syncstream> int main() { { std::osyncstream bout(std::cout); bout << "Hello," << '\n'; // no flush bout.emit(); // characters transferred; cout not flushed bout << "World!" << std::endl; // flush noted; cout not flushed bout.emit(); // characters transferred; cout flushed 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 を破棄し、その内部バッファを出力する(public member function) | |
| 内部バッファ全体をラップされたstreambufにアトミックに送信する ( std::basic_syncbuf<CharT,Traits,Allocator>のpublicメンバ関数) |