Namensräume
Varianten
Aktionen

std::flush

Aus cppreference.com
< cpp‎ | io‎ | manip

 
 
Input / Output-Bibliothek
I / O-Manipulatoren
C-style I / O
Puffern
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(veraltet)
Streams
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Abstraktionen
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
Datei-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
String 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
Array 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(veraltet)
ostrstream(veraltet)
strstream(veraltet)
Types
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
Fehler Kategorie Schnittstelle
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)
 
Eingang / Ausgang Manipulatoren
Gleitkomma-Formatierung
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.
Integer-Formatierung
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.
Boolean Formatierung
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
Feldbreite und fill Kontrolle
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.
Andere Formatierungen
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.
Whitespace-Verarbeitung
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.
Output Spülung
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
Statusflags Manipulation
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.
Zeit und Geld 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)
 
definiert in Header <ostream>
template< class CharT, class Traits >
std::basic_ostream<charT,traits>& flush( std::basic_ostream<CharT, Traits>& os );
Spült die Ausgangsfolge os, als ob durch den Aufruf 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.
Dies ist ein Nur-Ausgabe-I / O-Manipulators, kann es mit einem Expressionsvektor wie out << std::flush für jede out vom Typ std::basic_ostream aufgerufen werden .
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.

Inhaltsverzeichnis

[Bearbeiten] Notes

Dieser Manipulator kann verwendet werden, um eine unvollständige Zeile der Ausgabe sofort produzieren werden, zB bei der Anzeige Ausgang eines lang andauernden Prozesses, Logging-Aktivität von mehreren Threads oder Protokollierung Aktivität eines Programms, das unerwartet abstürzen kann. Eine explizite Flush von std::cout ist auch vor einem Aufruf von std::system erforderlich, wenn die erzeugten Prozess führt alle Bildschirm-I / O (Ein gängiges Beispiel ist std::system("pause") unter Windows). In den meisten anderen üblichen interaktiven I / O Szenarien ist std::endl überflüssig, wenn mit std::cout verwendet, da jeder Eingang von std::cin, Ausgabe auf std::cerr oder Beendigung des Programms zwingt einen Anruf an 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.
Wenn eine komplette Zeile der Ausgabe gespült werden muss, kann die std::endl Manipulators verwendet werden .
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.
Wenn jede Ausgabe-Operation gespült werden muss, kann die std::unitbuf Manipulators verwendet werden .
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.

[Bearbeiten] Parameter

os -
Verweis auf Ausgabe-Stream
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.

[Bearbeiten] Rückgabewert

os (Verweis auf den Stream nach Manipulation)
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.

[Bearbeiten] Beispiel

Ohne std :: flush, würde die Ausgabe identisch sein, kann aber nicht in Echtzeit angezeigt .
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)..

[Bearbeiten] Siehe auch

Kontrollen, ob die Ausgabe nach jeder Operation wird gespült
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.

(Funktion) [edit]
Ausgänge '\n' und spült den Ausgabe-Stream
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.

(Funktions-Template) [edit]
synchronisiert mit dem zugrunde liegenden Speicher
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.

(öffentliche Elementfunktion of std::basic_ostream) [edit]