Move of class with pimpl won't compile <p>In the following example, how is it possible that ~CImpl is called correctly but when the class needs to be moved, the compiler says it has an incomplete type?</p> <p>If the declaration of Impl is moved to the header it works, my question is how come the destructor is called fine so it doesn't seem that the type is incomplete, but the problem appears when moving.</p> <p>file: C.hpp</p> <pre><code>#include &lt;memory&gt; class Impl; class C { public: C(); ~C(); C(C&amp;&amp;) = default; C&amp; operator=(C&amp;&amp;) = default; std::unique_ptr&lt;Impl&gt; p; }; </code></pre> <p>file C.cpp</p> <pre><code>#include "C.hpp" #include &lt;iostream&gt; using namespace std; class Impl { public: Impl() {} virtual ~Impl() = default; virtual void f() = 0; }; class CImpl: public Impl { public: ~CImpl() { cout &lt;&lt; "~CImpl()" &lt;&lt; endl; } void f() { cout &lt;&lt; "f()" &lt;&lt; endl; } }; C::C(): p(new CImpl()) {} C::~C() </code></pre> <p>file: main.cpp</p> <pre><code>#include &lt;iostream&gt; #include &lt;vector&gt; #include "C.hpp" using namespace std; int main(int argc, char *argv[]) { vector&lt;C&gt; vc; // this won't compile //vc.emplace_back(C()); C c; C c2 = move(c); // this won't compile } </code></pre> <p>Compiler output:</p> <pre><code>+ clang++ -std=c++11 -Wall -c C.cpp + clang++ -std=c++11 -Wall -c main.cpp In file included from main.cpp:3: In file included from ./C.hpp:1: In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/memory:80: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/unique_ptr.h:65:16: error: invalid application of 'sizeof' to an incomplete type 'Impl' static_assert(sizeof(_Tp)&gt;0, ^~~~~~~~~~~ /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/unique_ptr.h:184:4: note: in instantiation of member function 'std::default_delete&lt;Impl&gt;::operator()' requested here get_deleter()(__ptr); ^ ./C.hpp:12:5: note: in instantiation of member function 'std::unique_ptr&lt;Impl, std::default_delete&lt;Impl&gt; &gt;::~unique_ptr' requested here C(C&amp;&amp;) = default; ^ ./C.hpp:3:7: note: forward declaration of 'Impl' class Impl; ^ 1 error generated. </code></pre>