fork download
  1. #include <iostream>
  2. #include <numeric>
  3. #include <vector>
  4.  
  5. namespace std
  6. {
  7.  
  8. inline std::ostream& operator<<(
  9. std::ostream& os, const std::vector<int>& scope)
  10. {
  11. os << '[';
  12.  
  13. auto iter = scope.cbegin();
  14. const auto endIter = scope.cend();
  15. if (iter != endIter)
  16. {
  17. os << *iter; // print first element
  18. while (++iter != endIter) // and all other elements
  19. {
  20. os << ", ";
  21. os << *iter;
  22. }
  23. }
  24.  
  25. os << ']';
  26.  
  27. return os;
  28. }
  29.  
  30. } // namespace std
  31.  
  32. int main()
  33. {
  34. std::vector<int> v(10);
  35. std::iota(v.begin(), v.end(), 1);
  36.  
  37. std::cout << v;
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]