构造初始化读取输入流字符的istreambuf_iterator。
istreambuf_iterator(
streambuf_type* _Strbuf = 0
) throw( );
istreambuf_iterator(
istream_type& _Istr
) throw( );
参数
_Strbuf
istreambuf_iterator 附加超出缓冲区。_Istr
istreambuf_iterator 附加输入流。
备注
第一个构造函数初始化。_Strbuf的进入流缓冲区指针。第二个构造函数初始化。_Istr的进入流缓冲区指针。rdbuf,最终然后尝试提取和存储类型 CharType对象。
示例
// istreambuf_iterator_istreambuf_iterator.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <algorithm>
#include <iostream>
int main( )
{
using namespace std;
// Following declarations will not compile:
istreambuf_iterator<char>::istream_type &istrm = cin;
istreambuf_iterator<char>::streambuf_type *strmbf = cin.rdbuf( );
cout << "(Try the example: 'Oh what a world!'\n"
<< " then an Enter key to insert into the output,\n"
<< " & use a ctrl-Z Enter key combination to exit): ";
istreambuf_iterator<char> charReadIn ( cin );
ostreambuf_iterator<char> charOut ( cout );
// Used in conjunction with replace_copy algorithm
// to insert into output stream and replace spaces
// with hyphen-separators
replace_copy ( charReadIn , istreambuf_iterator<char>( ),
charOut , ' ' , '-' );
}
Oh what a world!
噢,神奇的世界! (请尝试该示例:“噢,神奇的世界!”然后插入到输出中,然后使用的enter键CTRL Z enter键组合退出):噢,神奇的世界!哦什么world!^Z
要求
标头: <iterator>
命名空间: std