using templates with multiple object types
<p>I need to write a container template class <code>&lt;T, R&gt;</code> where T is an object and R can be either <code>vector&lt;T*&gt;</code> or <code>list&lt;T*&gt;</code>. i need to support common operations like insert(T) size() etc...</p>

<p>I am holding a class member called <code>T data</code> to be the list or the vector. the problem is, how do i write the code so at runtime i know which operation to invoke from <code>std::list</code> or <code>std::vector</code> ? </p>

<p>for example, to get the fist element in the container i would have to invoke <code>data[0]</code> in the vector case and <code>data.front()</code> in lists case. should i just use <code>typeid</code> operator ?</p>

<pre><code>if (typeid(R) ==  typeid(vector&lt;T*&gt;))
  then ...
else if (typeid(R) == typeid(list&lt;T*&gt;))
 then ...
</code></pre>

<p>Or is there a better way ? </p>
