title: Reallocation of nested c++ vectors
body: <p>Let us say that we have a structure including an <code>std::vector</code> container:</p>
  
  <pre><code>struct A {
      char a;  // decoration
      vector&lt;int&gt; v;
  
      A() {}
  };
  </code></pre>
  
  <p>At some point in our code, we have an <code>std::vector</code> storing those <code>A</code> structures (that means, two levels of <code>std::vector</code>s), and after that, we reserve more memory space for <code>v</code> on one of its elements:</p>
  
  <pre><code>    /*...*/
      vector&lt;A&gt; vect;
      vect.resize(10, A());
      vector&lt;A&gt;* vect_ptr = &amp;vect;
      vect[0].v.reserve(9999999);
      cout &lt;&lt; vect_ptr &lt;&lt; " ?= " &lt;&lt; &amp;vect &lt;&lt; endl;
      /*...*/
  </code></pre>
  
  <p>The question is: after reserving space for one of the 'low-level' vectors <code>v</code>, does it exist the risk that the 'high-level' vector <code>vect</code> is reallocated, making the pointer <code>vect_ptr</code> invalid?</p>
  
  <p>In affirmative case, would be redefining <code>v</code> as a reference a solution? (even though it adds an indirection level):</p>
  
  <pre><code>struct A {
      char a;
      vector&lt;int&gt;&amp; v;
  
      A() : v(vector&lt;int&gt;()) {}
  };
  </code></pre>