Espaços nominais
Variantes
Acções

std::cerr, std::wcerr

Da cppreference.com
< cpp‎ | io

 
 
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.
(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.
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.
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.
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.
(obsoleta)
(obsoleta)
(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.
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.
(C++11)
 
std::basic_ostream
Objetos globais
Original:
Global objects
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cerrwcerr
Funções de membro
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ostream::basic_ostream
basic_ostream::~basic_ostream
basic_ostream::operator=(C++11)
Entrada formatada
Original:
Formatted input
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ostream::operator<<
Entrada não formatado
Original:
Unformatted input
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ostream::put
basic_ostream::write
Posicionamento
Original:
Positioning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ostream::tellp
basic_ostream::seekp
Diversos
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ostream::flush
basic_ostream::swap(C++11)
Aulas-Membros
Original:
Member classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_ostream::sentry
Não-membros funções
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
Definido no cabeçalho <iostream>
extern std::ostream cerr;
(1)
extern std::wostream wcerr;
(2)
Os objectos globais std::cerr e std::wcerr saída de controle de fluxo de um tampão de aplicação (tipo definido derivado de std::streambuf e std::wstreambuf, respectivamente), associado com o padrão de fluxo de saída de erro C stderr.
Original:
The global objects std::cerr and std::wcerr control output to a stream buffer of implementation-defined type (derived from std::streambuf and std::wstreambuf, respectively), associated with the standard C error output stream stderr.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Esses objetos são garantidos para ser construído antes de o primeiro construtor de um objeto estático é chamado e eles são garantidos para sobreviver à última destruidor de um objeto estático, de modo que é sempre possível escrever para std::cerr no código do usuário.
Original:
These objects are guaranteed to be constructed before the first constructor of a static object is called and they are guaranteed to outlive the last destructor of a static object, so that it is always possible to write to std::cerr in user code.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
A menos que sync_with_stdio(false) foi emitido, ele é seguro para acessar simultaneamente esses objetos de vários segmentos, tanto para saída formatada e não formatado.
Original:
Unless sync_with_stdio(false) has been issued, it is safe to concurrently access these objects from multiple threads for both formatted and unformatted output.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Uma vez inicializado, std::cerr.flags() & unitbuf != 0 significado (o mesmo para wcerr) que qualquer saída enviada para esses objetos de fluxo é imediatamente liberado para o OS (via destruidor de std::basic_ostream::sentry).
Original:
Once initialized, std::cerr.flags() & unitbuf != 0 (same for wcerr) meaning that any output sent to these stream objects is immediately flushed to the OS (via std::basic_ostream::sentry's destructor).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Além disso, std::cerr.tie() retornos &std::cout (mesmo para wcerr e wcout), o que significa que qualquer operação de saída em std::cerr primeiro executa std::cout.flush() (via construtor de std::basic_ostream::sentry) (desde C++11)
Original:
In addition, std::cerr.tie() returns &std::cout (same for wcerr and wcout), meaning that any output operation on std::cerr first executes std::cout.flush() (via std::basic_ostream::sentry's constructor) (desde C++11)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Exemplo

saída para stderr via ondas de cerr fora a saída dependendo cout, enquanto a produção de stderr via obstrução não
Original:
output to stderr via cerr flushes out the pending output on cout, while output to stderr via clog does not
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <thread>
#include <iostream>
#include <chrono>
void f()
{
    std::cout << "Output from thread...";
    std::this_thread::sleep_for(std::chrono::seconds(2));
    std::cout << "...thread calls flush()" << std::endl;
}
 
int main()
{
    std::thread t1(f);
    std::this_thread::sleep_for(std::chrono::seconds(1));
    std::clog << "This output from main is not tie()'d to cout\n";
    std::cerr << "This output is tie()'d to cout\n";
    t1.join();
}

Saída:

This output from main is not tie()'d to cout
Output from thread...This output is tie()'d to cout
...thread calls flush()

[editar] Veja também

inicializa objetos de fluxo padrão
Original:
initializes standard stream objects
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(of std::ios_base public class membro) [edit]
escreve para o padrão stderr
(objeto global) fluxo de erro C
Original:
writes to the standard C error stream stderr
(objeto global)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[edit]
grava o padrão de fluxo de saída stdout
(objeto global) C
Original:
writes to the standard C output stream stdout
(objeto global)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[edit]