title: How can I use C++11 variadic templates to define a vector-of-tuples backed by a tuple-of-vectors?
body: <p>Suppose I have a bunch of vectors:</p>
  
  <pre><code>vector&lt;int&gt; v1;
  vector&lt;double&gt; v2;
  vector&lt;int&gt; v3;
  </code></pre>
  
  <p>all of the same length. Now, for every index i, I would like to be able to treat (v1[i], v2[i], v3[i]) as a tuple, and maybe pass it around. In fact, I want to have a a vector-of-tuples rather than a tuple-of-vectors, using which I can do the above. (In C terms, I might say an array-of-structs rather than a struct-of-arrays). I do not want to effect any data reordering (think: really long vectors), i.e. the new vector is backed by the individual vectors I pass in. Let's .</p>
  
  <p>Now, I want the class I write (call it <code>ToVBackedVoT</code> for lack of a better name) to support any arbitrary choice of vectors to back it (not just 3, not int, double and int, not every just scalars). I want the vector-of-tuples to be mutable, and for no copies to be made on construction/assignments. </p>
  
  <p>If I understand correctly, variadic templates and the new <code>std::tuple</code> type in C++11 are the means for doing this (assuming I don't want untyped <code>void*</code> arrays and such). However, I only barely know them and have never worked with them. Can you help me sketch out how such a class will look like? Or how, given</p>
  
  <pre><code>template &lt;typename ... Ts&gt;
  </code></pre>
  
  <p>I can express something like "the list of template arguments being the replacement of each typename in the original template arguments with a vector of elements of this type"?</p>
  
  <p><strong>Note:</strong> I think I might also want to later be able to adjoin additional vectors to the backing vectors, making an instance of <code>ToVBackedVoT&lt;int, double, int&gt;</code> into, say, an instance of <code>ToVBackedVoT&lt;int, double, int, unsigned int&gt;</code>. So, bear that in mind when answering. This is not critically important though.</p>