title: C++: Forward declaration of a class with a deleter for a unique pointer that can be repeated
body: <p>In C++, it is possible to use forward declaration to allow pointers to an incomplete type.</p>
  
  <pre><code>class A;
  A *p;
  </code></pre>
  
  <p>However, in some cases I want to declare a unique pointer instead, so I use</p>
  
  <pre><code>class A;
  class A_Deleter { void operator()(A*); }
  unique_ptr&lt;A, A_Deleter&gt; p;
  </code></pre>
  
  <p>This is adequate in many cases, but has one major disadvantage. Unlike a real forward declaration, it cannot be written twice. I.e. while this code compiles:</p>
  
  <pre><code>class A;
  class A;
  </code></pre>
  
  <p>This one doesn't:</p>
  
  <pre><code>class A;
  class A_Deleter { void operator()(A*); }
  class A;
  class A_Deleter { void operator()(A*); }
  </code></pre>
  
  <p>How would you forward declare a deleteable class?</p>