quote:Original post by Sneftel
Both of these approaches, however, don't allow for field separators. And certain field separators (commas between values, but not before the first or after the last value) would be extremely difficult to handle gracefully within STL algorithms.
This isn't that bad:
template<class OS, typename FI>OS& write_cvs(OS& os, const FI& begin, const FI& end) { if(begin!=end) { copy(begin, end-1, ostream_iterator<int>(os, ", ")); cout << *(end-1); cout << endl; } return os; }
[edited by - Magmai Kai Holmlor on September 16, 2002 8:53:19 PM]