title: Passing std::unique_ptr to constructor to take ownership
body: <p>I want to pass a <code>std::unique_ptr</code> to the constructor of a class that will take ownership of the data owned by the <code>std::unique_ptr</code>.</p>
  
  <p>Are there any differences between the approaches <code>foo</code> and <code>bar</code> below in terms of how the compiler handles them that would make one of them preferable?</p>
  
  <p><code>foo</code> class:</p>
  
  <pre><code>template &lt;class T&gt;
  class foo
  {
      std::unique_ptr&lt;T&gt; data_;
  
  public:
      foo(std::unique_ptr&lt;T&gt;&amp;&amp; data) :
          data_{ std::forward&lt;std::unique_ptr&lt;T&gt;&gt;(data) }
      {
      }
  };
  </code></pre>
  
  <p><code>bar</code> class:</p>
  
  <pre><code>template &lt;class T&gt;
  class bar
  {
      std::unique_ptr&lt;T&gt; data_;
  
  public:
      bar(std::unique_ptr&lt;T&gt; data) :
          data_{ std::move(data) }
      {
      }
  };
  </code></pre>