fork(1) download
  1. #include <iostream>
  2. #include <array>
  3. #include <vector>
  4. #include <deque>
  5. #include <string>
  6. using namespace std;
  7.  
  8. template<typename T>
  9. void print_container(const T& begin, const T& end)
  10. {
  11. for(T current = begin; current != end; ++current)
  12. std::cout << *current << " ";
  13. std::cout << std::endl;
  14. }
  15.  
  16. int main() {
  17. int array[] {1, 2, 3, 4, 5};
  18. print_container((int*)array, array + 5);
  19.  
  20. std::array<int, 4> stdarray {10, 20, 30, 40};
  21. print_container(stdarray.begin(), stdarray.end());
  22.  
  23. std::vector<std::string> vector {"one", "two", "three"};
  24. print_container(vector.begin(), vector.end());
  25.  
  26. std::deque<const char*> deque {"one", "two", "three"};
  27. print_container(deque.begin(), deque.end());
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
1 2 3 4 5 
10 20 30 40 
one two three 
one two three