Espaces de noms
Variantes
Affichages
Actions

std::endl

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

 
 
D'entrée / sortie de bibliothèque
I / O manipulateurs
C-style I / O
Tampons
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 (obsolète)
Cours d'eau
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Abstractions
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
Fichier E / 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
Chaîne 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
Tableau 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 (obsolète)
ostrstream (obsolète)
strstream (obsolète)
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
Interface catégorie d'erreur
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)
 
D'entrée / sortie manipulateurs
À virgule flottante en forme
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.
Formatage entier
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.
Formatage booléen
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
Largeur de champ et de contrôle de remplissage
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.
Autre mise en forme
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.
Traitement des espaces blancs
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.
Sortie de rinçage
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
Indicateurs d'état 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.
Temps et d'argent 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 );
Insère un caractère fin de ligne dans le os séquence de sortie et les bouffées comme si en appelant os.put(os.widen('\n')) suivie par 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.
Il s'agit d'un manipulateur de sortie uniquement d'E / S, il peut être appelé avec une expression telle que pour tout out << std::endl out de std::basic_ostream type .
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.

Sommaire

[modifier] Notes

Ce manipulateur peut être utilisé pour produire une ligne de sortie immédiatement, par exemple lors de l'affichage de sortie d'un processus de longue durée, l'activité forestière de plusieurs threads ou journalisation de l'activité d'un programme qui peut se bloquer de façon inattendue. Un rinçage explicite de std::cout est également nécessaire avant un appel à std::system, si le processus a engendré exécute n'importe quel écran I / O (un exemple courant est std::system("pause") sous Windows). Dans la plupart des autres habituels entrée / sortie interactive scénarios, std::endl est redondante lorsqu'il est utilisé avec std::cout car toute entrée de std::cin, sortie à std::cerr, ou la fin du programme oblige un appel à std::cout.flush(). L'utilisation de std::endl à la place de '\n', encouragé par certaines sources, peut considérablement dégrader les performances de sortie .
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.
Dans de nombreuses implémentations, la sortie standard est un tampon de ligne, et '\n' écriture provoque une chasse d'eau de toute façon, à moins std::cout.sync_with_stdio(false) a été exécuté. Dans ces situations, endl inutiles ne se dégrade que la performance de fichier de sortie, pas de sortie standard .
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.
Les exemples de code de ce wiki follow Bjarne Stroustrup dans le rinçage de la sortie standard qu'en cas de nécessité .
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.
Quand une ligne incomplète de sortie doit être balayé, le manipulateur peut être utilisé 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.
Lorsque tous les caractères de sortie doit être balayé, le manipulateur peut être utilisé 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.

[modifier] Paramètres

os -
référence aux flux de sortie
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.

[modifier] Retourne la valeur

os (référence au flux après la 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.

[modifier] Exemple

Avec \ n au lieu de endl, la sortie serait le même, mais peut ne pas apparaître en temps réel .
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);
    }
}

Résultat :

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

[modifier] Voir aussi

contrôle si la sortie est vidé après chaque opération
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.

(fonction) [edit]
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) [edit]
synchronise avec le dispositif de stockage sous-jacent
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.

(fonction membre publique de std::basic_ostream) [edit]