a template function printing the content of a STL container


👍 g++ -std=c++11 print_container.cpp
👍 ./a.out 
3 1 4 1 5 9 2 6 
3 1 4 1 5 9 2 6 
👍 cat print_container.cpp 
#include <iostream>
#include <vector>
#include <list>
using namespace std;

template<typename C>
void prt(C c) {
  for(auto i=c.begin();i!=c.end();++i) 
    cout << *i << ' ';
  cout << endl;
}

int main() {
  vector<int> v{3,1,4,1,5,9,2,6};
  list<int> l{3,1,4,1,5,9,2,6};
  prt(v);
  prt(l);
}