title: What does unique_ptr<T>::operator= do in terms of deallocation
body: <p>I'm having troubles understanding fully the assignment operator for unique_ptr. I understand that we can only move them, due to the fact that copy constructor and assignment operators are deleted, but what if 
  a unique_ptr which contains already an allocation is overwritten by a move operation? Is the content previously stored in the smart pointer free'd?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  
  class A{
  public:
      A() = default;
      virtual void act() const {
          std::cout &lt;&lt; "act from A" &lt;&lt; std::endl;
      }
      virtual ~A() {
          std::cout &lt;&lt; "destroyed A" &lt;&lt; std::endl;
      }
  };
  class B : public A {
  public:
      B() : A{} {}
      void act() const override {
          std::cout &lt;&lt; "act from B" &lt;&lt; std::endl;
      }
  
      ~B() override {
          std::cout &lt;&lt; "destroyed from B " &lt;&lt; std::endl;
      }
  };
  int main() {
      auto pP{std::make_unique&lt;A&gt;()};
      pP-&gt;act();
  
      ==================== ! =======================
      pP = std::make_unique&lt;B&gt;(); // || std::move(std::make_unique&lt;B&gt;())
      ==================== ! =======================
  
      pP-&gt;act();
      return 0;
  }
  </code></pre>
  
  <p>When I do </p>
  
  <pre><code>pP = std::make_unique&lt;B&gt;();
  </code></pre>
  
  <p>does it mean that what was allocated in the first lines for pP (new A()) is destructed automatically? 
  Or should I opt for:</p>
  
  <pre><code>pP.reset();
  pP = std::make_unique&lt;B&gt;();
  </code></pre>