title: Is assiging a shared_ptr to itself safe?
body: <p>Is it safe to self-assign a <code>std::shared_ptr</code>? So here is an example:</p>
  
  <pre><code>std::shared_ptr&lt;std::vector&lt;std::string&gt;&gt; pVec = std::make_shared&lt;std::vector&lt;std::string&gt;&gt;();
  
  std::cout &lt;&lt; pVec.use_count() &lt;&lt; std::endl; // 1
  pVec = pVec;
  </code></pre>
  
  <p>I know that assigning a <code>shared_ptr</code> object:</p>
  
  <ul>
  <li>will decrement the left hand side (LHS) operand reference count (RC), and then will check whether it is 0 (these previous operations are done atomically) and if so release the resource;</li>
  <li>also, will increment the right hand side (RHS) RC.</li>
  </ul>
  
  <p>So in this example the object is the same on both LHS and RHS and the ordering of these two RC changes inside the assignment operator is unspecified.</p>
  
  <p>I don't really know what happens exactly in case of self assignment.</p>