title: Forward Declarations and std::unique_ptr
body: <p>I am having trouble making forward declarations work with std::unique_ptr.  I have read other similar posts on SO and elsewhere online, but either the answers in those posts do not directly address my concern, or I am misinterpreting/misunderstanding the answers.  So, in case someone feels that this is a duplicate question (esp. with reference to <a href="https://stackoverflow.com/questions/6012157/is-stdunique-ptrt-required-to-know-the-full-definition-of-t">Is std::unique_ptr&lt;T&gt; required to know the full definition of T?</a>), please clarify how the answers in the original question help my example below, because I tried and could not figure it out.</p>
  <p>To illustrate the issues I am running into, I have built a project with the following code files:</p>
  <pre><code>//main.cpp
  int main(int argv, char* argv[]) { return 0;}
  
  //Composite.h
  #pragma once
  #include&lt;memory&gt;
  
  class Individual;
  
  class Composite
  {
  public:
      Composite();
      ~Composite();
  private:
      std::unique_ptr&lt;Individual&gt; mInd;
  };
  
  //Composite.cpp
  #include &quot;Composite.h&quot;
  
  Composite::Composite() {}
  Composite::~Composite() {}
  
  //Individual.h
  #pragma once
  class Individual
  {
  public:
      Individual();
      ~Individual();
  };
  
  //Individual.cpp
  #include &quot;Individual.h&quot;
  
  Individual::Individual() {}
  Individual::~Individual() {}
  </code></pre>
  <p>I am unable to compile the above project in Visual Studio 2017.  Essentially the compiler complains of:</p>
  <blockquote>
  <p>Error C2027: use of undefined type &quot;Individual&quot;</p>
  <p>Error C2338: can't delete an incomplete type</p>
  </blockquote>
  <p>Note that neither <code>Composite</code> nor <code>Individual</code> is instantiated, which is on purpose to illustrate the problem.  Whatever I found on SO and elsewhere online seems to suggest the above files should compile because:</p>
  <ol>
  <li>The compiler needs to know the complete definition of <code>Individual</code> before <code>Composite</code> is instantiated.  Since <code>Composite</code> is never instantiated, there should be no compilation errors.</li>
  <li>A number of solutions online suggest that defining an empty destructor in the .cpp file (instead of defining it in the header file) should resolve issues related to std::unique_ptr and incomplete types.  I have done that in the above files.</li>
  </ol>
  <p>So, why the compilation errors?</p>
  <p>P.S. I have read the post at <a href="https://stackoverflow.com/questions/6012157/is-stdunique-ptrt-required-to-know-the-full-definition-of-t">Is std::unique_ptr&lt;T&gt; required to know the full definition of T?</a>. There is a table provided in the accepted answer that I cannot make any sense of.  The constructor/destructor requirements in that table... does it apply to the owning class or the class for which the std::unique_ptr is constructed?  In fact, the third comment to the answer essentially advises to provide some clarification, but the comment was not responded to as far as I can tell.</p>
  <p>Thanks in advance to all those who bothered to help.</p>