title: Table implementation in C++
body: <p>In our C++ project I have a need in some combined data structure, I think it should be very similar to SQL table. I have a set of arrays (std::vectors) of a same size with different data types. e.g.:</p>
  
  <pre><code>time(int), X(double), Y(double), valid(boolean), number_of_measurements(int)
  </code></pre>
  
  <p>Let's pretend they are like a table, I need to have an access to them row-wise. For example I need a functionality to insert a row into an arbitrary position of the table which will cause a shift of all rows on one element down, kill row. I might need to sort the table by time, merge it with other tables of a same type. </p>
  
  <p>Is there anything like this in C++ world?</p>
  
  <p>Basically I need an universal solution, which supports any number of columns and rows. And of course the performance makes sense, so I prefer doing it rather in memory than in database.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I see many people are proposing to define a simple row structure and store it in a collection. No this is not going to fly as far as I have a need to frequently operate with columns. E.g. I may need to multiply the whole column or calculate a mean value out of it. I can even interpolate it or apply many different algorithms on a certain column.</p>
  
  <p>And I want to avoid a situation when I extract a column to a vector, apply some algorithms on it and then put it back to a structure. It looks ugly, doesn't it?</p>
  
  <p>I need more or less similar to this:</p>
  
  <pre><code>// Initializing: (three columns: time, X, Y)
  table t("time", std::vector&lt;int&gt;(), "X", std::vector&lt;double&gt;(), "Y", std::vector&lt;double&gt;());
  
  // inserting a row
  t.insert_row( 1, 20.0f, 20.0f );
  
  // accessing values:
  t["time"][10] = 20;
  
  // getting a column:
  std::vector&lt;int&gt; time = t["time"];
  
  // sorting
  t.sort_by( "time" );
  </code></pre>
  
  <p>Any thoughts?</p>