[Assorted-commits] SF.net SVN: assorted:[904] cpp-commons/trunk/src/commons/streams.h
Brought to you by:
yangzhang
From: <yan...@us...> - 2008-07-24 16:25:33
|
Revision: 904 http://assorted.svn.sourceforge.net/assorted/?rev=904&view=rev Author: yangzhang Date: 2008-07-24 16:25:42 +0000 (Thu, 24 Jul 2008) Log Message: ----------- added streams Added Paths: ----------- cpp-commons/trunk/src/commons/streams.h Added: cpp-commons/trunk/src/commons/streams.h =================================================================== --- cpp-commons/trunk/src/commons/streams.h (rev 0) +++ cpp-commons/trunk/src/commons/streams.h 2008-07-24 16:25:42 UTC (rev 904) @@ -0,0 +1,24 @@ +#ifndef COMMONS_STREAMS_H +#define COMMONS_STREAMS_H + +#include <ostream> +#include <vector> + +namespace commons { + + using namespace std; + + // Pretty-prints a vector of ostreamables. + template <typename T> + ostream& operator<<(ostream& out, const vector<T> &v) { + out << "["; + if (!v.empty()) { + for (typename vector<T>::size_type i = 0; i < v.size() - 1; i++) + out << v[i] << ", "; + out << v.back(); + } + return out << "]"; + } +} + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |