title: Why does std::vector work with incomplete types in class definitions?
body: <p>The following question came up:</p>
  
  <p>The c++ standard seems to say, that <code>std::vector</code> requires a complete type to work. (See <a href="https://en.cppreference.com/w/cpp/container/vector" rel="noreferrer">https://en.cppreference.com/w/cpp/container/vector</a> ) Then, why does the following code still compile?</p>
  
  <pre><code>#include &lt;vector&gt;
  
  struct parent;
  
  struct child
  {
      std::vector&lt;parent&gt; parents; //parent is incomplete here!
  };
  
  struct parent
  {
      std::vector&lt;child&gt; children;
  };
  </code></pre>
  
  <p>This seems counterintuitive. If <code>std::vector</code> requires a complete type, then <code>std::vector&lt;parent&gt;</code> should not compile because only its forward declaration is known inside the class definition of <code>child</code>.</p>
  
  <ul>
  <li>Is this behaviour something special about class definitions?</li>
  <li>Did I get it wrong, and <code>std::vector</code> does not require a complete type?</li>
  <li>Or, is this just a fluke? In that technically this isn't allowed, but it works for all implementations anyways...</li>
  </ul>
  
  <p><strong>EDIT</strong></p>
  
  <p>There seems to be a difference between c++11 and c++17. I would like to understand the c++11 version.</p>