Espacios de nombres
Variantes
Acciones

std::endl

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

 
 
Entrada / salida de la biblioteca
I / O manipuladores
C-estilo I / O
Buffers
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(obsoleto)
Arroyos
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Abstracciones
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
File 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
Cadena de 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
Matriz 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(obsoleto)
ostrstream(obsoleto)
strstream(obsoleto)
Tipos
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
Error interfaz categoría
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)
 
Entrada / salida manipuladores
De punto flotante de formato
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.
Formato Integer
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.
Formato booleano
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
Ancho de campo y de control de llenado
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.
Otros formatos
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.
Los espacios en blanco de procesamiento
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.
Salida de lavado
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
Indicadores de estado manipulación
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.
Tiempo y dinero 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 );
Inserta un carácter en la línea de fondo os secuencia de salida y los colores como si llamando os.put(os.widen('\n')) seguido por 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.
Este es un manipulador de sólo salida I / O, puede ser llamada con una expresión como out << std::endl para cualquier out de std::basic_ostream tipo .
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.

Contenido

[editar] Notas

Este manipulador puede ser usado para producir una línea de salida de forma inmediata, por ejemplo, cuando se muestra la salida de un proceso de larga duración, la actividad de registro de múltiples hilos o el registro de actividad de un programa que se puede bloquear de forma inesperada. Un rubor de explícito std::cout también es necesaria antes de una llamada a std::system, si el proceso creado realiza cualquiera de las pantallas de E / S (un ejemplo común es std::system("pause") en Windows). En la mayoría de otros habituales interactiva de E / S escenarios, std::endl es redundante cuando se utiliza con std::cout porque cualquier entrada de std::cin, salida a std::cerr o terminación programa obliga a una llamada a std::cout.flush(). El uso de std::endl en lugar de '\n', alentado por algunas fuentes, puede degradar significativamente el rendimiento de salida .
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.
En muchas implementaciones, la salida estándar es la línea de búfer, y '\n' escritura provoca una descarga de todos modos, a menos std::cout.sync_with_stdio(false) fue ejecutado. En esas situaciones, endl innecesario sólo degrada el rendimiento del archivo de salida no, la salida estándar .
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.
Los ejemplos de código en este wiki follow Bjarne Stroustrup en la salida estándar de lavado sólo cuando sea necesario .
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.
Cuando una línea incompleta de salida necesita ser lavado, el manipulador std::flush se puede utilizar .
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.
Cuando todos los personajes de salida necesita ser lavado, el manipulador std::unitbuf se puede utilizar .
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.

[editar] Parámetros

os -
referencia a la secuencia de salida
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.

[editar] Valor de retorno

os (referencia a la corriente después de la manipulación)
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.

[editar] Ejemplo

Con \ n en lugar de endl, la salida será la misma, pero no puede aparecer en tiempo real .
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);
    }
}

Output:

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

[editar] Ver también

controla si la salida se limpia después de cada operación
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.

(función) [edit]
vacía el flujo de salida
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.

(función de plantilla) [edit]
sincroniza con el dispositivo de almacenamiento subyacente
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.

(miembro público of std::basic_ostream función) [edit]