title: How to move a unique_ptr without custom deleter to another unique_ptr with custom deleter?
body: <pre class="lang-cpp prettyprint-override"><code>#include &lt;memory&gt;
  #include &lt;functional&gt;
  #include &lt;iostream&gt;
  
  struct TestStruct {
      int a = 100;
  };
  
  struct StructDeleter {
      void operator()(TestStruct *ptr) const {
          delete ptr;
      }
  };
  
  std::unique_ptr&lt;TestStruct, StructDeleter&gt; MakeNewStruct() {
      std::unique_ptr&lt;TestStruct&gt; st(new TestStruct());
  
      std::unique_ptr&lt;TestStruct, StructDeleter&gt; customDeleterSt(std::move(st));
      std::cout &lt;&lt; customDeleterSt-&gt;a &lt;&lt; std::endl;
      return customDeleterSt;
  }
  
  int main() {
      auto a = MakeNewStruct();
      std::cout &lt;&lt; a-&gt;a &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  <p>The above code can not be compiled, how to move <code>st</code> to <code>customDeleterSt</code>?
  I get a <code>st</code> unique_ptr from the <code>st</code> creation interface, and I use the custom deleter to hide the implementation of <code>st</code> from my users, so how to move a unique_ptr without custom deleter to a unique_tr with custom deleter?</p>
  <p>Thanks for any help!</p>