Standard C++ Library Class Reference

ostream_iterator<int> out(cout," ");
copy(v1.begin(),v1.end(),out);
cout << endl;
copy(v2.begin(),v2.end(),out);
cout << endl;
copy(v3.begin(),v3.end(),out);
cout << endl;
// Generate 3 values for cout
generate_n(ostream_iterator<int>(cout," "),3,gen);
cout << endl;
return 0;
}
Output :
2 4 8 16
2 4 8 4
2 4 8 16 32
2 4 8
Warnings
If your compiler does not support default template parameters, then you need to always supply
the Allocator template argument. For instance, you'll have to write:
vector<int, allocator>
instead of :
vector<int>
See Also
Function Objects