名前空間
変種
操作

std::basic_istream::sync

提供: cppreference.com
< cpp‎ | io‎ | basic istream

 
 
入力/出力ライブラリ
I / Oのマニピュレータ
CスタイルのI / O
バッファ
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(廃止予定)
ストリーム
Original:
Streams
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
抽象化
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
ファイル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
文字列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
アレイの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(廃止予定)
ostrstream(廃止予定)
strstream(廃止予定)
タイプ
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
エラーカテゴリインターフェース
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)
 
std::basic_istream
グローバルオブジェクト
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.
cin
wcin
メンバ関数
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_istream::basic_istream
basic_istream::~basic_istream
basic_istream::operator=(C++11)
書式付き入力
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_istream::operator>>
書式なし入力
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_istream::get
basic_istream::peek
basic_istream::unget
basic_istream::putback
basic_istream::getline
basic_istream::ignore
basic_istream::read
basic_istream::readsome
basic_istream::gcount
ポジショニング
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_istream::tellg
basic_istream::seekg
その他
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_istream::sync
basic_istream::swap(C++11)
メンバークラス
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_istream::sentry
非メンバ関数
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.
operator>>(std::basic_istream)
 
int sync();
データソースに関連付けられた入力バッファを同期させ.
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.
UnformattedInputFunctionが影響されない点を除いて、gcount()として動作します。構築し、監視オブジェクトをチェックした後、
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.
rdbuf()がnullポインタの場合、返品-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.
それ以外の場合は、rdbuf()->pubsync()呼び出します。その関数が-1返す場合、setstate(badbit)とリターン-1呼び出します。それ以外の場合、返品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.

目次

[編集] パラメータ

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

[編集] 値を返します

0成功、失敗に-1上またはストリームが(バッファリングされていないです)この操作をサポートしていない場合.
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.

[編集] ノート

readsome()と同様に、この関数はライブラリが提供するストリームを使って何を行うかどうかを実装定義である。意図は、ストリームバッファが最後にget領域を埋めた後、関連する入力系列に対して行われた変更をピックアップして、次の読み取り操作のために典型的である。ことを達成するために、sync()はget領域を空にしたり、それはそれを補充することもあれば、何もしないことがあります。標準入力ストリームで呼び出された場合に、この操作が未処理の入力を破棄する場合に注意すべき例外は、Visual Studioのです.
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.

[編集]

いくつかのプラットフォーム上で実装されているように、ファイル入力で、入力ストリームの同期()の使用方法を示しています.
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

[編集] も参照してください

[仮想]
関連文字シーケンスでバッファを同期させます
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.

(仮想protectedメンバ関数of std::basic_streambuf) [edit]
基本となるストレージデバイスとの同期を行います
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) [edit]