istreambuf_iterator::istreambuf_iterator
建構初始化從輸入資料流讀取字元的 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-df224314e5b14e14a2496d78371e901c-9423bff0ad3c4d5b8ec3590cbbd0326d
需求
標頭:<迭代器>
命名空間: std