std::basic_syncbuf
| ヘッダ <syncstream> で定義 |
||
| template< class CharT, |
(C++20以降) | |
std::basic_syncbufはstd::basic_streambuf (コンストラクタ時にポインタとして提供) のラッパーである。自身の内部バッファに出力を蓄積し、デストラクタ時に、また明示的に要求されたときに、その全内容をラップされたバッファにアトミックに送信する。これにより、連続した文字のシーケンスとして現れる。同じバッファに対して行われる他のすべての出力が、おそらく異なるstd::basic_syncbufのインスタンスを介して行われる限り、データ競合や、ラップされたバッファに送信される文字のインターリービングがないことを保証する。
std::basic_syncbufの典型的な実装は、ラップされたstd::basic_streambufへのポインタ、バッファが同期 (フラッシュ) 時に内容をラップされたバッファに送信するかどうかを示すブールフラグ、同期時に発行しないポリシーの場合に保留中のフラッシュを示すブールフラグ、Allocator (例: std::string) を使用する内部バッファ、および同じラップされたストリームバッファにアクセスする複数のスレッド間で発行を同期するために使用されるミューテックスへのポインタ (これらのミューテックスは、std::basic_streambufオブジェクトへのポインタをキーとして使用するハッシュマップに存在する場合がある) を保持する。
他のストリームバッファクラスと同様に、std::basic_syncbufは通常、直接ではなく、対応するストリームであるstd::osyncstreamを介してのみアクセスされる。
一般的な文字型のためにいくつかの typedef が提供されています
| ヘッダ
<syncstream> で定義 | |
| 型 | 定義 |
std::syncbuf
|
std::basic_syncbuf<char> |
std::wsyncbuf
|
std::basic_syncbuf<wchar_t> |
目次 |
[編集] メンバ型
| メンバ型 | 定義 |
char_type
|
CharT |
traits_type
|
Traits; Traits::char_type が CharT でない場合、プログラムは不適格となる。 |
int_type
|
Traits::int_type |
pos_type
|
Traits::pos_type |
off_type
|
Traits::off_type |
allocator_type
|
アロケータ
|
streambuf_type
|
std::basic_streambuf<CharT, Traits> |
[編集] メンバ関数
公開メンバ関数 | |
basic_syncbufオブジェクトを構築する(public メンバ関数) | |
basic_syncbufオブジェクトを代入する(public メンバ関数) | |
2つのbasic_syncbufオブジェクトをスワップする(public メンバ関数) | |
basic_syncbufを破棄し、内部バッファを出力する(public メンバ関数) | |
| 内部バッファ全体をラップされたstreambufにアトミックに送信する (public メンバ関数) | |
| ラップされたstreambufポインタを取得する (public メンバ関数) | |
このbasic_syncbufで使用されるアロケータを取得する(public メンバ関数) | |
| 現在のemit-on-syncポリシーを変更する (public メンバ関数) | |
Protected member functions | |
| 現在のemit-on-syncポリシーに応じて、発行するか、保留中のフラッシュを記録する (public メンバ関数) | |
[編集] 非メンバ関数
| std::swap アルゴリズムを特殊化する (関数テンプレート) |
std::basic_streambuf から継承
メンバ型
| メンバ型 | 定義 |
char_type
|
CharT |
traits_type
|
Traits; Traits::char_type が CharT でない場合、プログラムは不適格となる。 |
int_type
|
Traits::int_type |
pos_type
|
Traits::pos_type |
off_type
|
Traits::off_type |
メンバ関数
| [virtual] |
basic_streambuf オブジェクトを破棄する( std::basic_streambuf<CharT,Traits> の仮想 public メンバ関数) |
ロケール | |
| 関連するロケールを変更し、imbue() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| 関連するロケールのコピーを取得する ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
位置付け | |
| setbuf() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| seekoff() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| seekpos() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| sync() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
取得領域 | |
| 取得領域ですぐに利用可能な文字数を取得する ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| 入力シーケンスを進め、その後、再度進めずに1文字を読み取る ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| (C++17 で削除) |
入力シーケンスから1文字を読み込み、シーケンスを進める ( std::basic_streambuf<CharT,Traits> の public メンバ関数) |
| シーケンスを進めずに、入力シーケンスから1文字を読み取る ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| xsgetn() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
配置領域 | |
| 配置領域に1文字を書き込み、次のポインタを進める ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| xsputn() を呼び出す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
戻し | |
| 1文字を入力シーケンスに戻す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
| 入力シーケンスの次のポインタを1つ戻す ( std::basic_streambuf<CharT,Traits> の public メンバ関数) | |
Protected member functions
basic_streambuf オブジェクトを構築する(protected メンバ関数) | |
| (C++11) |
basic_streambuf オブジェクトを置き換える(protected メンバ関数) |
| (C++11) |
2つの basic_streambuf オブジェクトをスワップする(protected メンバ関数) |
ロケール | |
| [virtual] |
関連するロケールの変更に対応する ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
位置付け | |
| [virtual] |
許可されていれば、バッファをユーザー定義配列で置き換える ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
入力シーケンス、出力シーケンス、またはその両方で、相対アドレス指定を使用して次のポインタを再配置する ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
入力シーケンス、出力シーケンス、またはその両方で、絶対アドレス指定を使用して次のポインタを再配置する ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
バッファを関連付けられた文字シーケンスと同期する ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
取得領域 | |
| [virtual] |
分かっていれば、関連付けられた入力シーケンスで入力に利用可能な文字数を取得する ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
関連付けられた入力シーケンスから取得領域に文字を読み込む ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
関連付けられた入力シーケンスから取得領域に文字を読み込み、次のポインタを進める ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
入力シーケンスから複数の文字を読み込む ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| 取得領域の先頭、現在の文字、および末尾へのポインタを返す (protected メンバ関数) | |
| 入力シーケンスの次のポインタを進める (protected メンバ関数) | |
| 入力シーケンスの先頭、次、および末尾のポインタを再配置する (protected メンバ関数) | |
配置領域 | |
| [virtual] |
出力シーケンスに複数の文字を書き込む ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| [virtual] |
関連付けられた出力シーケンスに、配置領域から文字を書き込む ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
| 配置領域の先頭、現在の文字、および末尾へのポインタを返す (protected メンバ関数) | |
| 出力シーケンスの次のポインタを進める (protected メンバ関数) | |
| 出力シーケンスの先頭、次、および末尾のポインタを再配置する (protected メンバ関数) | |
戻し | |
| [virtual] |
入力シーケンスに1文字を戻す (入力シーケンスを変更する可能性あり) ( std::basic_streambuf<CharT,Traits> の仮想 protected メンバ関数) |
[編集] 備考
| 機能テストマクロ | 値 | 規格 | 機能 |
|---|---|---|---|
__cpp_lib_syncbuf |
201803L |
(C++20) | 同期バッファ付きostream (std::syncbuf, std::osyncstream) およびマニピュレータ |