fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. void print(const std::vector<int> x) noexcept
  5. {
  6. if (x.empty())
  7. {
  8. std::cout << "Empty vector!" << std::endl;
  9. return;
  10. }
  11.  
  12. for (const int i : x)
  13. {
  14. std::cout << i << ' ';
  15. }
  16. std::cout << std::endl;
  17. }
  18.  
  19. int main()
  20. {
  21. const std::vector<int> v{ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
  22. std::vector<int> w;
  23.  
  24. print(w);
  25.  
  26. w.insert(w.cend(), v.cbegin(), v.cend());
  27. print(w);
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
Empty vector!
0 1 2 3 4 5 6 7 8 9