Standard C++ Library Class Reference
Operators
const T&
operator= (const T& value);
Shift the value T onto the output stream.
const T& ostream_iterator<T>&
operator* ();
ostream_iterator<T>&
operator++();
ostream_iterator<T>
operator++ (int);
These operators all do nothing. They simply allow the iterator to be used in common
constructs.
Example
#include <iterator>
#include <numeric>
#include <deque>
#include <iostream.h>
int main ()
{
//
// Initialize a vector using an array.
//
int arr[4] = { 3,4,7,8 };
int total=0;
deque<int> d(arr+0, arr+4);
//
// stream the whole vector and a sum to cout
//
copy(d.begin(),d.end()-1,ostream_iterator<int>(cout," + "));
cout << *(d.end()-1) << " = " <<
accumulate(d.begin(),d.end(),total) << endl;
return 0;
}
Warning
If your compiler does not support default template parameters, then you need to always supply
the Allocator template argument. For instance, you will need to write :
deque<int, allocator>