title: How does returning std::make_unique<SubClass> work?
body: <p>I have a base class and its subclass:</p>
  
  <pre><code>class Base {
      public:
      virtual void hi() {
          cout &lt;&lt; "hi" &lt;&lt; endl;
      } 
  };
  
  class Derived : public Base {
      public:
      void hi() override {
          cout &lt;&lt; "derived hi" &lt;&lt; endl;
      } 
  };
  </code></pre>
  
  <p>Trying to create a helper function that creates a unique pointer of a Derived object.</p>
  
  <p>1) This one works:</p>
  
  <pre><code>std::unique_ptr&lt;Base&gt; GetDerived() {
      return std::make_unique&lt;Derived&gt;(); 
  }
  </code></pre>
  
  <p>2) But, this one fails to compile:</p>
  
  <pre><code>std::unique_ptr&lt;Base&gt; GetDerived2() { 
      auto a = std::make_unique&lt;Derived&gt;(); 
      return a; 
  }
  </code></pre>
  
  <p>3) std::move works:</p>
  
  <pre><code>std::unique_ptr&lt;Base&gt; GetDerived3() {
      auto a = std::make_unique&lt;Derived&gt;();
      return std::move(a); 
  }
  </code></pre>
  
  <p>4) If I create a Base instance, both work:</p>
  
  <pre><code>std::unique_ptr&lt;Base&gt; GetDerived4() {
      auto a = std::make_unique&lt;Base&gt;();
      return a; 
  }
  
  std::unique_ptr&lt;Base&gt; GetDerived5() {
      auto a = std::make_unique&lt;Base&gt;();
      return std::move(a); 
  }
  </code></pre>
  
  <p>Why (2) fails but others work? </p>