title: Templates and STL
body: <p>The following code represents a container based on std::vector</p>
  
  <pre><code>template &lt;typename Item&gt;
  struct TList
  {
      typedef std::vector &lt;Item&gt; Type;
  };
  
  
  template &lt;typename Item&gt;
  class List
  {
  private
              typename TList &lt;Item&gt;::Type items;
      ....
  }
  
  int main()
  {
    List &lt;Object&gt; list;
  }
  </code></pre>
  
  <p>Is it possible to templatize std::vector and create a general container, something like that?</p>
  
  <pre><code>template &lt;typename Item, typename stl_container&gt;
  struct TList
  {
      typedef stl_container&lt;Item&gt;;
  };
  </code></pre>
  
  <p>where stl_container represents std::vector, std::list, std::set...? I would like to choose the type of container at the time of the creation. </p>
  
  <pre><code>List &lt;Object, std::vector&gt; list; //vector of objects, not a real code
  List &lt;Object, std::vector&gt; list; //list of objects, not a real code
  </code></pre>
  
  <p>Thanks for your answers...</p>
  
  <p><strong>Updated question:</strong></p>
  
  <p>I tried the following code but there are errors:</p>
  
  <pre><code>#include &lt;vector&gt;
  template &lt;typename Item, typename Container&gt;
  struct TList
  {
     typedef typename Container &lt;Item&gt;::type type; //Error C2059: syntax error : '&lt;', Error C2238: unexpected token(s) preceding ';
  };
  
  
  template &lt;typename T&gt;
  struct vector_container
  {
    typedef std::vector&lt;T&gt; type;
  };
  
  int _tmain(int argc, _TCHAR* argv[])
  {
  TList &lt;int, vector_container&gt; v;
  TList &lt;int, map_container&gt; m;
  }
  </code></pre>