Espacios de nombres
Variantes

std::basic_istream::sync

De cppreference.com
 
 
Biblioteca de E/S
Manipuladores de E/S
E/S estilo C
Búferes
(en desuso en C++98)
Flujos
Abstracciones
E/S de archivos
E/S de cadenas
E/S de arrays
(en desuso en C++98)
(en desuso en C++98)
(en desuso en C++98)
Salida sincronizada
Tipos
Interfaz de categoría de error
(C++11)
 
std::basic_istream
Los objetos globales
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.
Las funciones miembro
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.
Entrada con formato
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.
Entrada sin formato
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.
Posicionamiento
Original:
Positioning
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Varios
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Clases de miembros
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.
Terceros funciones
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.
 
<tbody> </tbody>
int sync();
Sincroniza el buffer de entrada con la fuente de datos asociada .
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.
Se comporta como UnformattedInputFunction, excepto que gcount() no se ve afectada. Después de la construcción y comprobación del objeto centinela
Original:
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.
si rdbuf() es un puntero NULL, devuelve -1
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.
De lo contrario, las llamadas rdbuf()->pubsync(). Si la función devuelve -1, llama setstate(badbit) y vuelve -1. De lo contrario, devuelve 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.

Parámetros

(Ninguno)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Valor de retorno

0 en caso de éxito, -1 en caso de fallo o si la secuencia no admite esta operación (es 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.

Notas

Al igual que con readsome(), es definido por la implantación si esta función no hace nada con suministrados biblioteca arroyos. La intención es normalmente para leer la siguiente operación para recoger las modificaciones que se han realizado en la secuencia de entrada correspondiente después de la última memoria de flujo lleno obtener su área. Para lograrlo, sincronizar () puede vaciar la zona get, o puede rellenarlo, o puede no hacer nada. Una excepción notable es Visual Studio, donde esta operación descarta la entrada sin procesar cuando se llama con un flujo de entrada estándar .
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.

Ejemplo

Muestra el uso de corriente de entrada de sincronización () con el archivo de entrada, tal como se aplica en algunas 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.

#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';
}

Posible salida:

Reading from the file
abc
Reading from the file, with sync()
a23

Ver también

[virtual]
Sincroniza los búferes con la secuencia de caracteres asociada.
(función miembro virtual protegida de std::basic_streambuf<CharT,Traits>) [editar]

(función miembro pública de std::basic_ostream<CharT,Traits>) [editar]