 <p>Instead of taking a container as a parameter, take a pair of iterators:</p> <pre><code>template &lt;typename Iter&gt; void show(Iter first, Iter last) { while (first != last) { cout &lt;&lt; *first++; } } vector&lt;int&gt; v; show(v.begin(), v.end()); deque&lt;int&gt; d; show(d.begin(), d.end()); int arr[10]; show(begin(arr), end(arr)); </code></pre>