std::unitbuf, std::nounitbuf
De 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. |
Déclaré dans l'en-tête <ios>
|
||
std::ios_base& unitbuf( std::ios_base& str ); |
(1) | |
std::ios_base& nounitbuf( std::ios_base& str ); |
(2) | |
Active ou désactive rinçage automatique du courant de sortie après une opération de sortie. N'a aucun effet sur entrée .
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.
permet le drapeau
2) unitbuf
dans le flux str
comme si en appelant 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.
désactive le drapeau
unitbuf
dans le flux str
comme si en appelant 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.
Il s'agit d'un manipulateur d'E / S, il peut être appelé avec une expression telle que pour tout out << std::unitbuf
out
de std::basic_ostream type ou d'une expression telle que pour tout in >> std::unitbuf in
de std::basic_istream type .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.
Sommaire |
[modifier] Notes
Le rinçage est effectué dans le destructeur de l'objet std::basic_ostream::sentry, qui appelle str.rdbuf()->pubsync() si 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.
Les objets de sortie standard std::cerr et std::wcerr ont leur bit
unitbuf
fixé par défaut .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.
[modifier] Paramètres
str | - | référence aux flux d'entrée / sortie
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. |
[modifier] Retourne la valeur
str
(référence au flux après la 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.
[modifier] Exemple
Sans std :: unitbuf ou d'une autre couleur explicite, le résultat est le même, mais ne semble pas en temps réel .
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'; }
Résultat :
..(450 ms)....(902 ms)....(1352 ms)....(1802 ms)....(2252 ms)..
[modifier] Voir aussi
vide le flux de sortie 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. (fonction générique) | |
sorties '\n' et vide le flux de sortie 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. (fonction générique) |