Listing 1: Printing elements of a std::vector containing strings to std::cout.
template <typename T, typename Stream> class print_to_stream_t { Stream& stream_; public: print_to_stream_t(Stream& s):stream_(s) {} void operator()(const T& t) const { stream_ << t; } }; template <typename T,typename Stream> print_to_stream_t<T,Stream> print_to_stream(Stream& s) { return print_to_stream_t<T,Stream>(s); }