名前空間
変種
操作

std::endl

提供: 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>& endl( std::basic_ostream<CharT, Traits>& os );
挿入行末文字出力シーケンスosとフラッシュそこにとしてos.put(os.widen('\n'))続いos.flush()を呼び出したか.
Original:
Inserts a endline character into the output sequence os and flushes it as if by calling os.put(os.widen('\n')) followed by 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::endlのいずれoutためstd::basic_ostreamとして式と呼ばれるかもしれない.
Original:
This is an output-only I/O manipulator, it may be called with an expression such as out << std::endl 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::cout、出力から任意の入力がstd::cinへの呼び出しを強制するのでstd::cerrで使用する場合は、他のほとんどの通常の対話的なI / Oのシナリオでは、std::cout.flush()は冗長です。いくつかのソースに励まさstd::endlの代わりに'\n'の使用は、大幅に出力性能が低下する可能性があります.
Original:
This manipulator may be used to produce a 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(). Use of std::endl in place of '\n', encouraged by some sources, may significantly degrade output performance.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
多くの実装では、標準出力はラインバッファリングされており、'\n'が実行された場合を除きstd::cout.sync_with_stdio(false)を書くことは、とにかくフラッシュが発生します。そのような状況では、不要なendlのみファイル出力ではなく、標準出力の性能を低下させる.
Original:
In many implementations, standard output is line-buffered, and writing '\n' causes a flush anyway, unless std::cout.sync_with_stdio(false) was executed. In those situations, unnecessary endl only degrades the performance of file output, not standard output.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
必要な部分には、標準出力をフラッシュでこのwikifollow Bjarne Stroustrupのコードサンプル.
Original:
The code samples on this wiki follow Bjarne Stroustrup in flushing the standard output only where necessary.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
出力の不完全なラインをフラッシュする必要がある場合、std::flushマニピュレータを使用することができる.
Original:
When an incomplete line of output needs to be flushed, the std::flush 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 character of output 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.

[編集]

代わりにヒノキの\ nを指定すると、出力は同じになりますが、リアルタイムで表示されないことがあります.
Original:
With \n instead of endl, 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 passed" << std::endl;
}
int main()
{
    std::cout.sync_with_stdio(false); // on some platforms, stdout flushes on \n
    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);
    }
}

Output:

487 ms passed
974 ms passed
1470 ms passed
1965 ms passed
2455 ms passed

[編集] も参照してください

出力は各操作の後にフラッシュされるかどうかを制御します
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]
出力ストリームをフラッシュします
Original:
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]