Vector<short> in to std::ostream

Started by
19 comments, last by gimp 21 years, 7 months ago
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]
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

This topic is closed to new replies.

Advertisement