title: What is the correct usage of std::unique_ptr while pushing into std::vector
body: <p>I want to have a vector of pointers to objects in my class. To avoid making a destructor for it I wanted to use <code>std::unique_ptr</code>, as the objects are created/owned/destructed in my class, but I have a compiler error I can't understand. Next code will serve as a short sample for my problem:</p>
  
  <pre><code>std::unique_ptr&lt;int&gt; createPtr(int value)
  {
      std::unique_ptr&lt;int&gt; ptr(new int(value));
      return ptr;
  };
  
  int main()
  {
      std::vector&lt;std::unique_ptr&lt;int&gt;&gt; vec;
      vec.push_back(createPtr(1));
  
      std::unique_ptr&lt;int&gt; ptr = createPtr(2);
      vec.push_back(ptr);//error C2248: 'std::unique_ptr&lt;_Ty&gt;::unique_ptr' : cannot access private member declared in class 'std::unique_ptr&lt;_Ty&gt;'
  }
  </code></pre>
  
  <p>Can you please explain me why I get this error and what is the correct usage for <code>std::unique_ptr</code>?</p>