std::ostreambuf_iterator - cppreference.com
提供: cppreference.com
<tbody> </tbody> <tbody class="t-dcl-rev "> </tbody><tbody> </tbody>
| ヘッダ |
||
|
|
(C++17未満) | |
|
|
(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
|
void
|
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 を構築します (パブリックメンバ関数) [edit] | |
デストラクタ (暗黙に宣言) |
ostreambuf_iterator を破棄します (パブリックメンバ関数) [edit] |
| 紐付けられた出力ストリームに文字を書き込みます (パブリックメンバ関数) [edit] | |
| 何もしません (パブリックメンバ関数) [edit] | |
| 何もしません (パブリックメンバ関数) [edit] | |
| 出力が失敗したかどうか調べます (パブリックメンバ関数) [edit] |
例
#include <string> #include <algorithm> #include <iterator> #include <iostream> int main() { std::string s = "This is an example\n"; std::copy(s.begin(), s.end(), std::ostreambuf_iterator<char>(std::cout)); }
出力: