std::flush
提供: cppreference.com
|
|
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
| Defined in header <ostream>
|
||
| template< class CharT, class Traits > std::basic_ostream<charT,traits>& flush( std::basic_ostream<CharT, Traits>& os ); |
||
osとしてos.flush()を呼び出したかをフラッシュ出力シーケンス. Original:
Flushes the output sequence
os as if by calling os.flush(). The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
これは出力専用のI / Oマニピュレータである、そのようなタイプのout << std::flushのいずれ
outためstd::basic_ostreamとして式と呼ばれるかもしれない.Original:
This is an output-only I/O manipulator, it may be called with an expression such as out << std::flush for any
out of type std::basic_ostream.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集] ノート
このマニピュレータは、例えば、直ちに出力の不完全な行を生成するために使用することができる複数のスレッドの活動を記録したり、突然クラッシュする可能性があるプログラムの活動を記録、実行時間の長いプロセスからの出力を表示するとき。生成されたプロセスは、任意の画面を実行する場合std::coutの明示的なフラッシュは、std::systemをコールする前にも必要で、I / O(一般的な例では、Windows上でstd::system("pause")です)。 std::endlで使用する場合std::cout、std::cinへの出力、またはプログラムが終了することから、任意の入力がstd::cerrへの呼び出しを強制するので、他のほとんどの通常の対話的なI / Oのシナリオでは、std::cout.flush()は冗長です.
Original:
This manipulator may be used to produce an incomplete line of output immediately, e.g. when displaying output from a long-running process, logging activity of multiple threads or logging activity of a program that may crash unexpectedly. An explicit flush of std::cout is also necessary before a call to std::system, if the spawned process performs any screen I/O (a common example is std::system("pause") on Windows). In most other usual interactive I/O scenarios, std::endl is redundant when used with std::cout because any input from std::cin, output to std::cerr, or program termination forces a call to std::cout.flush().
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
出力の完全なラインをフラッシュする必要がある場合、std::endlマニピュレータを使用することができる.
Original:
When a complete line of output needs to be flushed, the std::endl manipulator may be used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
すべての出力動作をフラッシュする必要がある場合、std::unitbufマニピュレータを使用することができる.
Original:
When every output operation needs to be flushed, the std::unitbuf manipulator may be used.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] パラメータ
| os | - | 出力ストリームへの参照
Original: reference to output stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[編集] 値を返します
os(操作後のストリームへの参照)Original:
os (reference to the stream after manipulation)The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例
はstd ::フラッシュせずに、出力は同じになりますが、リアルタイムで表示されないことがあります.
Original:
Without std::flush, the output would be the same, but may not appear in real time.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
このコードを実行します
#include <iostream> #include <chrono> template<typename Diff> void log_progress(Diff d) { std::cout << "..(" << std::chrono::duration_cast<std::chrono::milliseconds>(d).count() << " ms).." << std::flush; } int main() { volatile int sink=0; auto t1 = std::chrono::high_resolution_clock::now(); for(int j=0; j<5; ++j) { for(int n=0; n<10000; ++n) for(int m=0; m<20000; ++m) sink += m*n; // do some work auto now = std::chrono::high_resolution_clock::now(); log_progress(now - t1); } std::cout << '\n'; }
出力:
..(450 ms)....(901 ms)....(1350 ms)....(1800 ms)....(2250 ms)..
[編集] 参照
| 出力は各操作の後にフラッシュされるかどうかを制御します Original: controls whether output is flushed after each operation The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数) | |
| 出力'\n'と出力ストリームをフラッシュします Original: outputs '\n' and flushes the output stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
| 基本となるストレージデバイスとの同期を行います Original: synchronizes with the underlying storage device The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数of std::basic_ostream)
| |