title: Understanding std::move and unique_ptr
body: <p>I am new to c++11 and trying to understand to meaning of <code>std::move</code> and <code>unique_ptr</code> and wrote the following code, which I use <code>std::move</code> on a <code>unique_ptr</code> in two different ways:</p>
  
  <pre><code>void unique_ptr_plain_move() {
    unique_ptr&lt;int&gt; intptr(new int(10));
    unique_ptr&lt;int&gt; intptr2;
  
    printf("*intptr = %d\n", *intptr);
    intptr2 = std::move(intptr);
    printf("*intptr2 = %d\n", *intptr2);
    // as expected, crash here as we have already moved intptr's ownership.
    printf("*intptr = %d\n", *intptr);
  }
  
  /////////////////////////////////////////////
  
  void function_call_move(unique_ptr&lt;int&gt;&amp;&amp; intptr) {
    printf("[func] *intptr = %d\n", *intptr);
  }
  
  void unique_ptr_function_call_move() {
    unique_ptr&lt;int&gt; intptr(new int(10));
  
    printf("*intptr = %d\n", *intptr);
    function_call_move(std::move(intptr));
    // this does not crash, intptr still has the ownership of its pointed instance ....
    printf("*intptr = %d\n", *intptr);
  }
  </code></pre>
  
  <p>In <code>unique_ptr_plain_move()</code>, <code>intptr2</code> takes the ownership of <code>intptr</code> after <code>std::move</code> and therefore we can no longer use <code>intptr</code>.  However, in <code>unique_ptr_function_call_move()</code>, when using <code>std::move</code> in a function call, <code>intptr</code> still have its ownership of its pointed instance.  Can I know what exactly happened when we pass a <code>std::move(unique_ptr)</code> to a function?  Thank you.</p>