fork download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <numeric>
  4. #include <vector>
  5.  
  6. namespace std
  7. {
  8.  
  9. inline std::ostream& operator<<(
  10. std::ostream& os, const std::vector<int>& v)
  11. {
  12. os << '[';
  13.  
  14. if (!v.empty())
  15. {
  16. os << v.front();
  17.  
  18. std::for_each(std::next(v.cbegin()), v.cend(),
  19. [&os](const int i){ os << ", " << i; });
  20. }
  21.  
  22. os << ']';
  23.  
  24. return os;
  25. }
  26.  
  27. } // namespace std
  28.  
  29. int main()
  30. {
  31. std::vector<int> v(10);
  32. std::iota(v.begin(), v.end(), 1);
  33.  
  34. std::cout << v;
  35.  
  36. return 0;
  37. }
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]