title: Generic vector of vectors in C++
body: <p>Is there a good way in C++ to implement (or fake) a type for a generic vector of vectors?</p>
  
  <p>Ignore the issue of when a vector of vectors is a good idea (unless there's something equivalent which is always better). Assume that it does accurately model the problem, and that a matrix does not accurately model the problem. Assume also that templated functions taking these things as parameters do need to manipulate the structure (e.g. calling push_back), so they can't just take a generic type supporting <code>[][]</code>.</p>
  
  <p>What I want to do is:</p>
  
  <pre><code>template&lt;typename T&gt;
  typedef vector&lt; vector&lt;T&gt; &gt; vecvec;
  
  vecvec&lt;int&gt; intSequences;
  vecvec&lt;string&gt; stringSequences;
  </code></pre>
  
  <p>but of course that's not possible, since typedef can't be templated.</p>
  
  <pre><code>#define vecvec(T) vector&lt; vector&lt;T&gt; &gt;
  </code></pre>
  
  <p>is close, and would save duplicating the type across every templated function which operates on vecvecs, but would not be popular with most C++ programmers.</p>