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の入力ストリーム バッファーのポインターを初期化します。 2 番目のコンストラクターは _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-763935d9b8ea4480abf97417b3299a0f-5568a13dbffa40df9100d5b4b11bf578
必要条件
ヘッダー: の <反復子>
名前空間: std