title: What is the advantage of a unique_ptr over a shared_ptr
body: <p>I'm currently learning about the <code>unique_ptr</code> and <code>shared_ptr</code> types in C++.  The advantages of smart pointers over raw pointers are apparent, and there are lots of explanations why you should prefer them over raw pointers.  What I'm struggling to understand is <strong>why you would ever specifically choose to use a <code>unique_ptr</code> over a <code>shared_ptr</code></strong>?</p>
  
  <p>As far as I can tell, from the programmers perspective (ignoring implementation) <strong>, a <code>unique_ptr</code>just seems like a special-case version of a <code>shared_ptr</code> where the reference count is restricted to one</strong>.  So if I create a <code>shared_ptr</code> and only ever create a single reference, then I basically have the utility of a <code>unique_ptr</code> (with the ability to use the <code>shared</code> part in the future).</p>
  
  <p>So what advantage does a <code>unique_ptr</code> give you?  I should admit that I approach this as a Java programmer and a <code>shared_ptr</code> seems pretty darn close to the way Java works.</p>