ostream_iterator::operator=
output_iterator の式 *i = 出力ストリームに書き込むことの x ) を実装するために使用する代入演算子です。
ostream_iterator<Type, CharType, Traits>& operator=(
const Type& _Val
);
パラメーター
- _Val
出力ストリームに挿入する型 Type のオブジェクトの値。
戻り値
演算子は、区切り記号に続く ostream_iterator のコンストラクター で指定されたオブジェクトに関連付けられた出力ストリームに _Val (存在する場合)、挿入し、ostream_iteratorへの参照を返します。
解説
満たしている必要が ostream_iterator 出力反復子の要件の式のみです。*ii = t は有効で、演算子または operator= に関して何も、単独で言いません。このメンバー演算子は *thisを返します。
使用例
// ostream_iterator_op_assign.cpp
// compile with: /EHsc
#include <iterator>
#include <vector>
#include <iostream>
int main( )
{
using namespace std;
// ostream_iterator for stream cout
// with new line delimiter
ostream_iterator<int> intOut ( cout , "\n" );
// Standard iterator interface for writing
// elements to the output stream
cout << "Elements written to output stream:" << endl;
*intOut = 10;
intOut++; // No effect on iterator position
*intOut = 20;
*intOut = 30;
}
必要条件
ヘッダー: <iterator>
名前空間: std