std::basic_istream::sync
Da cppreference.com
< cpp | io | basic istream
![]() |
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. |
int sync(); |
||
Sincroniza o buffer de entrada com a fonte de dados associada.
Original:
Synchronizes the input buffer with the associated data source.
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.
Se comporta como
UnformattedInputFunction
, exceto que gcount()
não é afetado. Depois de construir e verificar o objeto de sentinelaOriginal:
Behaves as
UnformattedInputFunction
, except that gcount()
is not affected. After constructing and checking the sentry object,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.
se rdbuf() é um ponteiro nulo, -1 retornos
Original:
if rdbuf() is a null pointer, returns -1
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.
Caso contrário, as chamadas rdbuf()->pubsync(). Se essa função retorna -1, chama setstate(badbit) e retorna -1. Caso contrário, retorna 0.
Original:
Otherwise, calls rdbuf()->pubsync(). If that function returns -1, calls setstate(badbit) and returns -1. Otherwise, returns 0.
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.
Índice |
[editar] Parâmetros
(Nenhum)
Original:
(none)
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.
[editar] Valor de retorno
0 em sucesso, -1 em falha ou se o fluxo não suporta esta operaç��o (é unbuffered).
Original:
0 on success, -1 on failure or if the stream does not support this operation (is unbuffered).
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.
[editar] Notas
Tal como acontece com
readsome()
, é definida pela implementação se esta função não faz nada com biblioteca fornecidos córregos. A intenção é tipicamente para a próxima operação de leitura para pegar quaisquer alterações que possam ter sido feitas para a seqüência de entrada associado após o buffer de fluxo passado encheu sua área de começar. Para isso, sincronizar () pode esvaziar a área get, ou pode recarregá-lo, ou pode fazer nada. Uma exceção notável é o Visual Studio, onde esta operação descarta a entrada não processado quando chamada com um fluxo de entrada padrão.Original:
As with
readsome()
, it is implementation-defined whether this function does anything with library-supplied streams. The intent is typically for the next read operation to pick up any changes that may have been made to the associated input sequence after the stream buffer last filled its get area. To achieve that, sync() may empty the get area, or it may refill it, or it may do nothing. A notable exception is Visual Studio, where this operation discards the unprocessed input when called with a standard input stream.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.
[editar] Exemplo
Demonstra o uso de sincronia fluxo de entrada () com entrada de arquivo, como implementado em algumas plataformas .
Original:
Demonstrates the use of input stream sync() with file input, as implemented on some platforms.
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 <fstream> void file_abc() { std::ofstream f("test.txt"); f << "abc\n"; } void file_123() { std::ofstream f("test.txt"); f << "123\n"; } int main() { file_abc(); // file now contains "abc" std::ifstream f("test.txt"); std::cout << "Reading from the file\n"; char c; f >> c; std::cout << c; file_123(); // file now contains "123" f >> c; std::cout << c; f >> c; std::cout << c << '\n'; f.close(); file_abc(); // file now contains "abc" f.open("test.txt"); std::cout << "Reading from the file, with sync()\n"; f >> c; std::cout << c; file_123(); // file now contains "123" f.sync(); f >> c; std::cout << c; f >> c; std::cout << c << '\n'; }
Potencial saída:
Reading from the file abc Reading from the file, with sync() a23
[editar] Veja também
[virtual] |
sincroniza os buffers com a seqüência de caracteres associado Original: synchronizes the buffers with the associated character sequence The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (virtual protegido of std::basic_streambuf função de membro)
|
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)
|