名前空間
変種
操作

std::flush

提供: cppreference.com
< cpp‎ | io‎ | manip

 
 
入力/出力ライブラリ
I / Oのマニピュレータ
CスタイルのI / O
バッファ
Original:
Buffers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_streambuf
basic_filebuf
basic_stringbuf
strstreambuf(廃止予定)
ストリーム
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
抽象化
Original:
Abstractions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ios_base
basic_ios
basic_istream
basic_ostream
basic_iostream
ファイルI / O
Original:
File I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ifstream
basic_ofstream
basic_fstream
文字列I / O
Original:
String I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_istringstream
basic_ostringstream
basic_stringstream
アレイのI / O
Original:
Array I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
istrstream(廃止予定)
ostrstream(廃止予定)
strstream(廃止予定)
タイプ
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
streamoff
streamsize
fpos
エラーカテゴリインターフェース
Original:
Error category interface
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
iostream_category(C++11)
io_errc(C++11)
 
入力/出力マニピュレータ
浮動小数点の書式
Original:
Floating-point formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
整数フォーマット
Original:
Integer formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ブールの書式
Original:
Boolean formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
boolalpha
noboolalpha
フィールド幅と塗りつぶしコントロール
Original:
Field width and fill control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
その他の書式
Original:
Other formatting
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
空白処理
Original:
Whitespace processing
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
出力がフラッシュします
Original:
Output flushing
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
flush
endl
ステータスフラグ操作
Original:
Status flags manipulation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
時間とお金のI / O
Original:
Time and money I/O
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
get_money(C++11)
get_time(C++11)
put_money(C++11)
put_time(C++11)
 
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.
これは出力専用の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.

目次

[編集] ノート

このマニピュレータは、例えば、直ちに出力の不完全な行を生成するために使用することができる複数のスレッドの活動を記録したり、突然クラッシュする可能性があるプログラムの活動を記録、実行時間の長いプロセスからの出力を表示するとき。生成されたプロセスは、任意の画面を実行する場合std::coutの明示的なフラッシュは、std::systemをコールする前にも必要で、I / O(一般的な例では、Windows上でstd::system("pause")です)。 std::endlで使用する場合std::coutstd::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.
出力の完全なラインをフラッシュする必要がある場合、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.
すべての出力動作をフラッシュする必要がある場合、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.

[編集] パラメータ

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.

[編集]

は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.

#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';
}

Output:

..(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.

(関数) [edit]
出力'\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.

(関数テンプレート) [edit]
基本となるストレージデバイスとの同期を行います
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) [edit]