std::basic_ostream<CharT,Traits>::flush
提供: cppreference.com
< cpp | io | basic ostream
basic_ostream& flush(); |
||
まだコミットしていない変更をベースとなる出力シーケンスに書き込みます。
rdbuf() がヌルポインタの場合は何もしません。
そうでなければ、 UnformattedOutputFunction として動作します (C++11以上)。 sentry オブジェクトの構築および確認の後、 rdbuf()->pubsync() を呼びます。 呼び出しが -1 を返した場合は setstate(badbit) を呼びます。
目次 |
[編集] 引数
(なし)
[編集] 戻り値
*this。
[編集] 例外
exceptions()&badbit!=0 の場合は std::ios_base::failure を投げる可能性があります。
[編集] 例
Run this code
#include <thread> #include <iostream> #include <chrono> void f() { std::cout << "Output from thread..."; std::this_thread::sleep_for(std::chrono::seconds(2)); std::cout << "...thread calls flush()\n"; std::cout.flush(); } int main() { std::thread t1(f); std::this_thread::sleep_for(std::chrono::seconds(1)); std::clog << "Output from main\n"; t1.join(); }
出力:
Output from main Output from thread.....thread calls flush()
[編集] 関連項目
sync() を呼びます ( std::basic_streambuf<CharT,Traits> のパブリックメンバ関数)
| |
[仮想] |
バッファを紐付けられている文字シーケンスと同期します ( std::basic_streambuf<CharT,Traits> の仮想プロテクテッドメンバ関数)
|
出力ストリームをフラッシュします (関数テンプレート) | |
'\n' を出力して出力ストリームをフラッシュします (関数テンプレート) | |
ベースとなるストレージデバイスと同期します ( std::basic_istream<CharT,Traits> のパブリックメンバ関数)
|