title: Why is iterator of container invalidated when this container is also an element of a container?
body: <pre><code>int main() {
      std::vector&lt;std::vector&lt;int&gt;&gt; v;
      v.push_back({1,2,3,4});
  
      auto it = v.at(0).begin();
      int size = v.at(0).size();
      std::cout&lt;&lt;size&lt;&lt;std::endl;
      for (int i = 0; i &lt; size; ++it)
      {
          v.push_back({5,6,7,8});
          //std::cout&lt;&lt;*it&lt;&lt;std::endl;
      }
  
      return 0;
  }
  </code></pre>
  
  <p>The iterator is broken when I push some elements into the outer container.
  what should I do if I really want to iterate the container element inside of outer container and at the same time keep pushing back some new elements ? Many thanks!</p>