title: Changing pointed to variable of unique_ptr
body: <p>I don't think I've understood the concept of smart pointers correctly.</p>
  
  <p>Have a look at this MWE:</p>
  
  <pre><code>// Example program
  #include &lt;iostream&gt;
  #include &lt;memory&gt;
  #include &lt;string&gt;
  
  struct P{
      float x, y;
      P() : x(0.f), y(0.f){}
      P(float x, float y) : x(x), y(y){}
      P(P&amp;&amp; q) : x(q.x), y(q.y){}
      P&amp; operator=(P&amp;&amp; q){
          x = q.x;
          y = q.y;
          return *this;
      }
      P&amp; operator=(const P&amp;) = delete;
      P(const P&amp;) = delete;
  
  };
  
  std::ostream&amp; operator&lt;&lt;(std::ostream&amp; out, const P&amp; p){ out &lt;&lt; p.x &lt;&lt; " / " &lt;&lt; p.y; return out;}
  
  int main(){    
      P p1{1.f, 0.f};
      P p2{2.f, 0.f};
  
      std::unique_ptr&lt;P&gt; p1Ptr(std::make_unique&lt;P&gt;(std::move(p1)));
      P* p2Ptr = &amp;p2;
  
      p1 = std::move(P{1.f, 1.f});
      p2 = std::move(P{2.f, 2.f});
  
      std::cout &lt;&lt; " p1: " &lt;&lt; p1 &lt;&lt; "\n";
      std::cout &lt;&lt; "*p1: " &lt;&lt; *p1Ptr &lt;&lt; "\n";
      std::cout &lt;&lt; "*p1: " &lt;&lt; *(p1Ptr.get()) &lt;&lt; "\n";
      std::cout &lt;&lt; " p2: " &lt;&lt; p2 &lt;&lt; "\n";
      std::cout &lt;&lt; "*p2: " &lt;&lt; *p2Ptr &lt;&lt; std::endl; 
  }
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <p>p1: 1 / 1<br>
    *p1: 1 / 0<br>
    *p1: 1 / 0<br>
    p2: 2 / 2<br>
    *p2: 2 / 2  </p>
  </blockquote>
  
  <p>I would have expected the <code>std::unique_ptr</code> to also see the value change of <code>p1</code>. However, this is not the case. How can I achieve this?</p>