取消引用运算符用于实现输出迭代器表达式*ii = x。
ostream_iterator<Type, CharType, Traits>& operator*( );
返回值
为 ostream_iterator的引用。
备注
ostream_iterator 必须满足的输出迭代的要求没有只需要表达式*ii = t 为有效且仅显示有关 operator 或 operator=。此实现的成员运算符返回 *this。
示例
// ostream_iterator_op_deref.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