fork(3) download
  1. #include <iostream>
  2. #include <ostream>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7. class foo {
  8. public:
  9. int bar;
  10. };
  11.  
  12. template <typename T>
  13. std::ostream& operator<< (std::ostream& out, const std::vector<T>& v) {
  14. if ( !v.empty() ) {
  15. out << '[';
  16.  
  17. for (auto i = v.begin(); i < v.end(); i++)
  18. out << *i << ", ";
  19. out << "]";
  20. }
  21. return out;
  22. }
  23.  
  24.  
  25. int main() {
  26. vector<foo> x {{1},{2}};
  27. vector<int> f {1,2,3};
  28. cout << f;
  29. return 0;
  30. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
[1, 2, 3, ]