std::basic_osyncstream<CharT,Traits,Allocator>::emit
來自 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 併發出其內部緩衝區(公開成員函式) | |
原子地將整個內部緩衝區傳輸到被包裝的 streambuf ( std::basic_syncbuf<CharT,Traits,Allocator> 的公開成員函式) |