std::ostreambuf_iterator
From cppreference.com
| ヘッダ <iterator> で定義 |
||
| template< class CharT, class Traits = std::char_traits<CharT> > class ostreambuf_iterator |
(C++17まで) | |
| template< class CharT, class Traits = std::char_traits<CharT> > class ostreambuf_iterator; |
(C++17以降) | |
std::ostreambuf_iterator は、構築された std::basic_streambuf オブジェクトに連続した文字を書き込む、シングルパスの LegacyOutputIterator です。実際の書き込み操作は、イテレータ(デリファレンスされたかどうかにかかわらず)に代入されたときに実行されます。std::ostreambuf_iterator のインクリメントは何も行いません。
典型的な実装では、std::ostreambuf_iterator の唯一のデータメンバーは、関連付けられた std::basic_streambuf へのポインタと、ファイルの終端条件に達したかどうかを示すブールフラグです。
目次 |
[編集] メンバ型
| メンバ型 | 定義 | ||||
iterator_category
|
std::output_iterator_tag | ||||
value_type
|
void | ||||
difference_type
|
| ||||
pointer
|
void | ||||
reference
|
void | ||||
char_type
|
CharT
| ||||
traits_type
|
Traits
| ||||
streambuf_type
|
std::basic_streambuf<CharT, Traits> | ||||
ostream_type
|
std::basic_ostream<CharT, Traits> |
|
メンバ型 |
(C++17まで) |
[編集] メンバ関数
新しい ostreambuf_iterator を構築します。(public メンバ関数) | |
| (デストラクタ) (暗黙的に宣言) |
ostreambuf_iterator を破棄します。(public メンバ関数) |
| 関連付けられた出力シーケンスに文字を書き込みます。 (public メンバ関数) | |
| 何も行わない (public メンバ関数) | |
| 何も行わない (public メンバ関数) | |
| 出力が失敗したかどうかをテストします。 (public メンバ関数) |
[編集] 例
このコードを実行
#include <algorithm> #include <iostream> #include <iterator> #include <string> int main() { std::string s = "This is an example\n"; std::copy(s.begin(), s.end(), std::ostreambuf_iterator<char>(std::cout)); }
出力
This is an example
[編集] 関連項目
| std::basic_streambuf から読み取る入力イテレータ (クラステンプレート) | |
| std::basic_ostream に書き込む出力イテレータ (クラステンプレート) |