std::ostreambuf_iterator::ostreambuf_iterator
ostreambuf_iterator( streambuf_type* buffer ); | (1) | |
---|---|---|
ostreambuf_iterator( ostream_type& stream ); | (2) | |
1%29使用私有构造迭代器。streambuf_type*
成员设置为buffer
失败的%28%29位设置为false
如果buffer
为空指针。
2%29ostreambuf_iterator(stream.rdbuf())
参数
stream | - | the output stream whose rdbuf() will be accessed by this iterator |
---|---|---|
buffer | - | the output stream buffer to be accessed by this iterator |
例外
(none) | (until C++11) |
---|---|
noexcept specification: noexcept | (since C++11) |
例
二次
#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';
}
二次
© cppreference.com
在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com