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!
噢World! (請嘗試這個範例:「執行world!」接著會插入至輸出中, __AMP__RYAN使用哪一個輸入鍵CTRL Z輸入按鍵組合結束):噢World!執行哪些World!^Z
需求
標題: <iterator>
命名空間: std