fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. std::ostream& operator<<(std::ostream& os, const std::vector<int>& v)
  5. {
  6. os << '{';
  7.  
  8. if (v.empty())
  9. os << " empty";
  10. else
  11. {
  12. for (auto e : v)
  13. os << ' ' << e;
  14. }
  15.  
  16. return os << " }";
  17. }
  18.  
  19. std::ostream& operator<<(std::ostream& os, const std::vector<std::vector<int>>& v)
  20. {
  21. for (auto e : v)
  22. os << e << '\n';
  23.  
  24. return os;
  25. }
  26.  
  27. int main()
  28. {
  29. std::vector<std::vector<int>> row{ { 1 }, { 2 }, { 3 }, { 4 } };
  30.  
  31. std::cout << row << '\n';
  32.  
  33. row[0].erase(row[0].begin());
  34.  
  35. std::cout << row << '\n';
  36. }
Success #stdin #stdout 0s 3276KB
stdin
Standard input is empty
stdout
{ 1 }
{ 2 }
{ 3 }
{ 4 }

{ empty }
{ 2 }
{ 3 }
{ 4 }