std::basic_osyncstream<CharT,Traits,Allocator>::emit
提供: cppreference.com
<tbody>
</tbody>
void emit(); |
||
ベースとなる std::basic_syncbuf に対して emit() を呼ぶことによって、バッファされているすべての出力を排出し、あらゆる保留中のフラッシュを実行します。
引数
(なし)
例
Run this code
#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 を破棄し、その内部バッファを排出します (パブリックメンバ関数) | |
| 内部バッファ全体をラップされた streambuf にアトミックに転送します ( std::basic_syncbuf<CharT,Traits,Allocator>のパブリックメンバ関数)
|