Espaços nominais
Variantes
Acções

std::endl

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

 
 
De entrada / saída da biblioteca
I / O manipuladores
C estilo de 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(obsoleta)
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.
Abstrações
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
Cordas 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 de 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(obsoleta)
ostrstream(obsoleta)
strstream(obsoleta)
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
Interface de categoria de erro
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 / saída manipuladores
De ponto flutuante de formatação
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.
Formatação inteiro
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.
Formatação booleana
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
Largura do campo e controle de preenchimento
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.
Outra formatação
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.
Espaços de processamento
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.
Saída de descarga
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
Sinalizadores de status manipulação
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.
Tempo e dinheiro 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 );
Insere um caractere de fim de linha para o os seqüência de saída e libera-lo como se chamando 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.
Esta é uma saída de somente manipulador de I / O, que pode ser chamada com uma indicação tal como para qualquer out << std::endl 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.

Índice

[editar] Notas

Este manipulador pode ser utilizado para produzir uma linha de saída, imediatamente, por exemplo, ao exibir a saída de um processo de longa duração, o registro da atividade de vários segmentos ou registrar a atividade de um programa que pode falhar inesperadamente. Um esvaziamento explícito de std::cout também é necessária antes de uma chamada para std::system, se o processo gerado executa qualquer tela de I / O (um exemplo comum é std::system("pause") no Windows). Na maioria dos outros habituais interativos / S cenários, std::endl é redundante quando usado com std::cout porque qualquer entrada de std::cin, saída para std::cerr, ou término do programa obriga uma chamada para std::cout.flush(). Uso de std::endl no lugar de '\n', incentivado por algumas fontes, pode degradar significativamente o desempenho saída.
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.
Em muitas implementações, a saída padrão é a linha-buffered, e '\n' escrita provoca uma descarga de qualquer maneira, a menos que std::cout.sync_with_stdio(false) foi executado. Nessas situações, endl desnecessário só degrada o desempenho de saída de arquivo não, a saída padrão.
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.
Os exemplos de código neste follow Bjarne Stroustrup wiki em Flushing a saída padrão apenas quando necessário.
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.
Quando uma linha incompleta de saída tem de ser lavada, o manipulador std::flush podem ser utilizados.
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.
Quando todos os caracteres de saída precisa ser lavada, o manipulador std::unitbuf pode ser usado.
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 -
referência ao fluxo de saída
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 (referência ao fluxo após a manipulação)
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] Exemplo

Com \ n em vez de endl, o resultado seria o mesmo, mas não pode aparecer em tempo 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] Veja também

controles se a saída é liberada após cada operação
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.

(função) [edit]
libera o fluxo de saída
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.

(modelo de função) [edit]
sincroniza com o dispositivo de armazenamento subjacente
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.

(of std::basic_ostream função pública membro) [edit]