◐ Shell
clean mode source ↗

std::basic_istream::sync – cppreference.com

Aus cppreference.com

<metanoindex/>

<tbody> </tbody>

Synchronisiert die Eingabepuffer mit der zugehörigen Datenquelle .

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.

Verhält sich wie UnformattedInputFunction, außer dass gcount() wird nicht beeinflusst. Nach dem Bau und Prüfung der Schildwache Objekt

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.

wenn

rdbuf()

ein NULL-Zeiger ist, kehrt -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.

Ansonsten ruft rdbuf()->pubsync(). Wenn diese Funktion gibt -1, ruft setstate(badbit) und kehrt -1. Ansonsten kehrt 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.

Parameter

(None)

Original:

(none)

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

Rückgabewert

0 bei Erfolg -1 bei Ausfall oder wenn der Strom nicht unterstützt diesen Vorgang (ungepuffert) .

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.

Notes

Wie bei readsome(), ist es durch die Implementierung definiert, ob diese Funktion nichts mit Bibliothek bereitgestellten Streams tut. Die Absicht ist in der Regel für den nächsten Lesevorgang abholen alle Änderungen, die mit dem zugehörigen Eingabesequenz vorgenommen wurden, nachdem der Stream-Puffer letzten füllte seine erhalten Gegend. Um das zu erreichen, synchronisieren () kann entleeren get-Bereich, oder es kann nachzufüllen, oder es kann nichts tun. Eine bemerkenswerte Ausnahme ist Visual Studio, wo diese Operation verwirft das unbearbeitete Eingangssignal, wenn sie mit einem Standard-Input-Stream genannt .

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.

Beispiel

Veranschaulicht die Verwendung von Input-Stream sync () mit Datei-Eingabe, wie auf einigen Plattformen nicht implementiert .

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

Possible output:

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

Siehe auch

synchronisiert die Puffer mit der zugehörigen Zeichenfolge

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.


(virtuellen geschützten Member-Funktion of std::basic_streambuf) [edit]

synchronisiert mit dem zugrunde liegenden Speicher

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.


(öffentliche Elementfunktion of std::basic_ostream) [edit]