fork download
  1. #include <iostream>
  2. #include <list>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <iterator>
  6. #include <string>
  7. using namespace std;
  8.  
  9. template <typename T, typename A, template <typename X, typename Y> class C>
  10. std::ostream &operator<<(std::ostream &os, const C<T,A> &container)
  11. {
  12. if(!container.empty())
  13. std::copy(container.begin(), container.end(), std::ostream_iterator<T>(os, " "));
  14. return os;
  15. }
  16.  
  17. int main() {
  18. list<int> l{1,2,3,4,5};
  19. vector<string> v{"one","two","three"};
  20. cout<<l<<endl<<v;
  21. return 0;
  22. }
Success #stdin #stdout 0s 4504KB
stdin
Standard input is empty
stdout
1 2 3 4 5 
one two three