title: C++ Assignment operator for class that contains a unique pointer member variable
body: <p>I understand that if I have a class with a smart unique pointer, it is not possible to assign that class to another instance, as a unique pointer cannot be copied. I understand that I could make the unique pointer a shared pointer and this would solve the problem. But what if I did not want to share ownership of the pointer? Is it possible to create an assignment operator that moves the unique pointer and copies the other variables?  </p>
  
  <p>I have read that you can use <code>std::move</code> to pass ownership.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt; 
  
  struct GraphStructure { };
  
  class test {
  
          int a;
          std::vector&lt;int&gt; vector;
          std::unique_ptr&lt;GraphStructure&gt; Graph_; 
   };
  
   int main () {
  
       test t1;
       auto t2 = t1;
   }
  </code></pre>