构造初始化读取输入流中的字符的 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 , ' ' , '-' );
}
噢 World!
FakePre-44526da4567b44e3b1bf18e016fed7ae-15cd45594e7c46abb2936692adffd9d3
要求
头文件: <iterator>
命名空间: std