title: unique_ptr, pimpl/forward declaration and complete definition
body: <p>I already checked out the questions <a href="https://stackoverflow.com/questions/13414652/forward-declaration-with-unique-ptr">here</a> and <a href="https://stackoverflow.com/questions/9020372/how-do-i-use-unique-ptr-for-pimpl">here</a>, but still cannot figure out what is wrong.</p>
  
  <p>This is the calling code:</p>
  
  <pre><code>#include "lib.h"
  
  using namespace lib;
  
  int
  main(const int argc, const char *argv[]) 
  {
      return 0;
  }
  </code></pre>
  
  <p>This is the lib code:</p>
  
  <pre><code>#ifndef lib_h
  #define lib_h
  
  #include &lt;string&gt;
  #include &lt;vector&gt;
  #include &lt;memory&gt;
  
  namespace lib
  {
  
  class Foo_impl;
  
  class Foo
  {
      public:
          Foo();
          ~Foo();
  
      private:
          Foo(const Foo&amp;);
          Foo&amp; operator=(const Foo&amp;);
  
          std::unique_ptr&lt;Foo_impl&gt; m_impl = nullptr;
  
          friend class Foo_impl;
  };
  
  } // namespace
  
  #endif
  </code></pre>
  
  <p>clang++ gives me this error:</p>
  
  <blockquote>
    <p>invalid application of 'sizeof' to an incomplete type 'lib::Foo_impl'
    <br/>note: in instantiation of member function 'std::default_delete::operator()' requested</p>
  </blockquote>
  
  <p>You can see I already specifically declared Foo destructor. What else am I missing here?</p>