ostream_iterator::operator*
Dereferencing operator used to implement the output iterator expression *ii = x.
ostream_iterator<Type, CharType, Traits>& operator*( );
Return Value
A reference to the ostream_iterator.
Remarks
The requirements for an output iterator that the ostream_iterator must satisfy require only the expression *ii = t be valid and says nothing about the operator or the operator= on their own. The member operator in this implementation returns *this.
Example
// 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;
}
Elements written to output stream: 10 20 30
Requirements
Header: <iterator>
Namespace: std