You simply use a template template parameter ( template template parameter subsection there ) like this:
template < template < typename > typename T > void printIntegers( T<int>& container )
{
for ( int el: container ) { std::cout << el << " " ; }
std::cout << std::endl;
}
int main()
{
std::vector<int> i{1,2,3,4};
std::list<int> l{7,8,9,10};
printIntegers( i );
printIntegers( l );
}
Some hints: In your code you did a copy instead of a reference by passing the container into your function. That will generate a lot of overhead by copying the content. The compiler may optimze it out, but you should write it with a reference to get a guarantee to not waste your memory with a copy.