title: C++ template implementation to store 2D nested vector data continuously?
body: <p>Storing a two-dimensional grid as <code>std::vector&lt;std::vector&lt;double&gt;&gt;</code> is rather inefficient because each of the inner vectors contains separately allocated heap memory.
  I am seeking a template implementation to let me do the things like:</p>
  <pre><code>nested_vector&lt;double, 2&gt; nv;
  nv.push_back({0, 1, 2});   // row1
  nv.push_back({3, 4});      // row2
  nv.push_back({5, 6, 7, 8});// row3
  </code></pre>
  <p>Ideal storage in memory:</p>
  <pre><code>-------------------------------------------------
  |     row 1     |     row 2     |     row 3     |
  -------------------------------------------------
  
  </code></pre>
  <p>instead of</p>
  <pre><code>std::vector&lt;std::vector&lt;double&gt;&gt;  v = {{0, 1, 2}, {3, 4}, {5, 6, 7, 8}};
  </code></pre>
  <pre><code>--------------
  |     row 1     |
  -------------
  |     row 2     |
  -------------
  |     row 3     |
  --------------
  
  
  </code></pre>
  <p>Is there any template implementation to do this?
  Any tips will be appreciated, thanks in advance.</p>