std::basic_osyncstream<CharT,Traits,Allocator>:: emit
From cppreference.net
<
cpp
|
io
|
basic osyncstream
C++
Input/output library
| I/O manipulators | ||||
| Print functions (C++23) | ||||
| C-style I/O | ||||
| Buffers | ||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(C++20)
|
||||
| Streams | ||||
| Abstractions | ||||
| File I/O | ||||
| String I/O | ||||
| Array I/O | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
|
(
C++98/26*
)
|
||||
| Synchronized Output | ||||
|
(C++20)
|
||||
| Types | ||||
| Error category interface | ||||
|
(C++11)
|
||||
|
(C++11)
|
std::basic_osyncstream
| Public member functions | ||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
(C++20)
|
||||
|
basic_osyncstream::emit
(C++20)
|
|
void
emit
(
)
;
|
||
バッファリングされたすべての出力を送信し、保留中のフラッシュを実行します。これは基盤となる emit() を呼び出すことで実現され、 std::basic_syncbuf を介して処理されます。
パラメータ
(なし)
例
このコードを実行
#include <iostream> #include <syncstream> int main() { { std::osyncstream bout(std::cout); bout << "Hello," << '\n'; // フラッシュなし bout.emit(); // 文字転送完了; coutはフラッシュされない bout << "World!" << std::endl; // フラッシュ指定; coutはフラッシュされない bout.emit(); // 文字転送完了; coutがフラッシュされる bout << "Greetings." << '\n'; // フラッシュなし } // デストラクタがemit()を呼び出し: 文字転送完了; coutはフラッシュされない // emitはラップされたストリームに対するローカルな例外処理に使用可能 std::osyncstream bout(std::cout); bout << "Hello, " << "World!" << '\n'; try { bout.emit(); } catch (...) { // 例外処理 } }
出力:
Hello, World! Greetings. Hello, World!
関連項目
basic_osyncstream
を破棄し、内部バッファを出力する
(public member function) |
|
|
内部バッファ全体をアトミックにラップされたstreambufに転送する
(
std::basic_syncbuf<CharT,Traits,Allocator>
のpublic member function)
|