fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <list>
  4. #include <algorithm>
  5. #include <iterator>
  6.  
  7. using namespace std;
  8.  
  9. template <typename Iterator>
  10. void printContainer(Iterator itBegin,
  11. Iterator itEnd)
  12. {
  13. copy(itBegin, itEnd, ostream_iterator<typename Iterator::value_type>(cout, " "));
  14. cout << endl;
  15. }
  16.  
  17. int main() {
  18. vector<int> v{1, 2, 3, 4, 5, 6};
  19. list<int> l{1, 2, 3, 4, 5, 6};
  20. printContainer(begin(v), end(v));
  21. printContainer(begin(l), end(l));
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
1 2 3 4 5 6 
1 2 3 4 5 6