fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <iterator>
  4.  
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. vector<int> coll{ 1, 2, 3, 4, 5 };
  12.  
  13. copy(coll.begin(), coll.end(), ostream_iterator<int>(cout, " "));
  14. cout << endl;
  15. cout << coll.capacity() << endl;
  16.  
  17. copy(coll.begin(), coll.end(), back_inserter(coll));
  18.  
  19. copy(coll.begin(), coll.end(), ostream_iterator<int>(cout, " "));
  20. cout << endl;
  21. cout << coll.capacity() << endl;
  22.  
  23. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
1 2 3 4 5 
5
1 2 3 4 5 1 2 3 4 5 
10