std::unitbuf, std::nounitbuf
Aus cppreference.com
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
definiert in Header <ios>
|
||
std::ios_base& unitbuf( std::ios_base& str ); |
(1) | |
std::ios_base& nounitbuf( std::ios_base& str ); |
(2) | |
Aktiviert oder deaktiviert die automatische Spülung der Ausgabe-Stream nach jedem Ausgabe-Operation. Hat keine Auswirkung auf Eingang .
1) Original:
Enables or disables automatic flushing of the output stream after any output operation. Has no effect on input.
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.
ermöglicht die
2) unitbuf
Flagge in den Strom str
, als ob durch den Aufruf str.setf(std::ios_base::unitbuf)Original:
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.
deaktiviert die
unitbuf
Flagge in den Strom str
, als ob durch den Aufruf str.unsetf(std::ios_base::unitbuf)Original:
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.
Dies ist ein I / O-Manipulators, kann es mit einem Expressionsvektor wie out << std::unitbuf für jede
out
vom Typ std::basic_ostream oder mit einem Expressionsvektor wie in >> std::unitbuf für jede in
vom Typ std::basic_istream aufgerufen werden .Original:
This is an I/O manipulator, it may be called with an expression such as out << std::unitbuf for any
out
of type std::basic_ostream or with an expression such as in >> std::unitbuf for any in
of type std::basic_istream.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.
Inhaltsverzeichnis |
[Bearbeiten] Notes
Flushing in der Destruktor der std::basic_ostream::sentry Objekt durchgeführt wird, nennt die str.rdbuf()->pubsync() wenn str.flags() & std::ios_base::unitbuf == true .
Original:
Flushing is performed in the destructor of the std::basic_ostream::sentry object, which calls str.rdbuf()->pubsync() if str.flags() & std::ios_base::unitbuf == true.
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.
Die Standard-Output-Objekte std::cerr und std::wcerr haben ihre
unitbuf
Bit standardmäßig eingestellt .Original:
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.
[Bearbeiten] Parameter
str | - | Verweisen auf I / O-Strom
Original: reference to I/O 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
str
(Verweis auf den Stream nach Manipulation)Original:
str
(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.
[Bearbeiten] Beispiel
Ohne std :: unitbuf oder anderen expliziten bündig, ist der Ausgang gleich, aber nicht in Echtzeit angezeigt .
Original:
Without std::unitbuf or another explicit flush, the output is the same, but does 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).."; } int main() { volatile int sink=0; std::cout << std::unitbuf; // enable automatic flushing 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)....(902 ms)....(1352 ms)....(1802 ms)....(2252 ms)..
[Bearbeiten] Siehe auch
spült die Ausgabe-Stream 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. (Funktions-Template) | |
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) |