std::ostreambuf_iterator<CharT,Traits>::ostreambuf_iterator
提供: cppreference.com
<tbody>
</tbody>
<tbody class="t-dcl-rev t-dcl-rev-num ">
</tbody><tbody>
</tbody>
<tbody class="t-dcl-rev t-dcl-rev-num ">
</tbody><tbody>
</tbody>
| (1) | ||
ostreambuf_iterator( streambuf_type* buffer ) throw(); |
(C++11未満) | |
ostreambuf_iterator( streambuf_type* buffer ) noexcept; |
(C++11以上) | |
| (2) | ||
ostreambuf_iterator( ostream_type& stream ) throw(); |
(C++11未満) | |
ostreambuf_iterator( ostream_type& stream ) noexcept; |
(C++11以上) | |
1)
buffer に設定したプライベートな streambuf_type* メンバと false に設定した failed() ビットを持つイテレータを構築します。 buffer がヌルポインタの場合、動作は未定義です。2)
ostreambuf_iterator(stream.rdbuf()) と同じです。引数
| stream | - | このイテレータによって rdbuf() がアクセスされる出力ストリーム |
| buffer | - | このイテレータによってアクセスされる出力ストリームバッファ |
例
Run this code
#include <iostream>
#include <fstream>
#include <iterator>
int main()
{
std::basic_filebuf<char> f;
f.open("test.txt", std::ios::out);
std::ostreambuf_iterator<char> out1(&f);
std::ostreambuf_iterator<wchar_t> out2(std::wcout);
*out1 = 'a';
*out2 = L'a';
}