title: Does unique_ptr release cause memory leaks?
body: <p>I'm confused about <code>unique_ptr.release()</code>. </p>
  
  <p>My goal is to cast a <a href="http://en.cppreference.com/w/cpp/memory/unique_ptr" rel="nofollow noreferrer">unique_ptr</a> of a base class to a <code>unique_ptr</code> of a derived class.</p>
  
  <p>So I found this <a href="https://stackoverflow.com/questions/17417848/stdunique-ptr-with-derived-class/17417920?noredirect=1#comment69296901_17417920">question</a>
  and the answer is </p>
  
  <pre><code>Derived *tmp = dynamic_cast&lt;Derived*&gt;(basePointer.get());
  std::unique_ptr&lt;Derived&gt; derivedPointer;
  if(tmp != nullptr)
  {
      basePointer.release();
      derivedPointer.reset(tmp);
  }
  </code></pre>
  
  <p>or</p>
  
  <pre><code>std::unique_ptr&lt;Derived&gt;
      derivedPointer(static_cast&lt;Derived*&gt;(basePointer.release()));
  </code></pre>
  
  <p>Then I was wondering what happen to the base pointer after <code>basePointer.release();</code>. </p>
  
  <p>Based on this <a href="https://stackoverflow.com/questions/25609457/unique-ptr-explicit-delete">question</a>, I understand that it causes a memory leak.</p>
  
  <p>Am I right?</p>