Namensräume
Varianten
Aktionen

std::unitbuf, std::nounitbuf

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.
unitbuf
nounitbuf
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 <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 .
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.
1)
ermöglicht die unitbuf Flagge in den Strom str, als ob durch den Aufruf str.setf(std::ios_base::unitbuf)
Original:
enables the unitbuf flag in the stream str as if by calling str.setf(std::ios_base::unitbuf)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
deaktiviert die unitbuf Flagge in den Strom str, als ob durch den Aufruf str.unsetf(std::ios_base::unitbuf)
Original:
disables the unitbuf flag in the stream str as if by calling str.unsetf(std::ios_base::unitbuf)
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 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.

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.
Die Standard-Output-Objekte std::cerr und std::wcerr haben ihre unitbuf Bit standardmäßig eingestellt .
Original:
The standard output objects std::cerr and std::wcerr have their unitbuf bit set by default.
The text has been machine-translated via Google Translate.
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.

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

#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) [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]