#ifndef __JOIN_H__ #define __JOIN_H__ #include <sstream> #include <iterator> template<class Iterator> std::string join(Iterator begin, Iterator end) { std::ostringstream io; for(Iterator i = begin; i != end; ++i) { io << *i; } return io.str(); } template<class Iterator, class Sep> std::string join(Iterator i, Iterator end, const Sep& sep) { std::ostringstream io; io << *i; while(++i != end) { io << sep << *i; } return io.str(); } #endif// __JOIN_H__