title: How to declare std::unique_ptr and what is the use of it?
body: <p>I try to understand how <code>std::unique_ptr</code> works and for that I found <a href="http://www.codeguru.com/cpp/article.php/c17775/The-Smart-Pointer-That-Makes-Your-C-Applications-Safer--stduniqueptr.htm" rel="noreferrer">this</a> document. The author starts from the following example:</p>
  <pre><code>#include &lt;utility&gt;  //declarations of unique_ptr
  using std::unique_ptr;
  // default construction
  unique_ptr&lt;int&gt; up; //creates an empty object
  // initialize with an argument
  unique_ptr&lt;int&gt; uptr (new int(3));
  double *pd= new double;
  unique_ptr&lt;double&gt; uptr2 (pd);
  // overloaded * and -&gt;
  *uptr2 = 23.5;
  unique_ptr&lt;std::string&gt; ups (new std::string(&quot;hello&quot;));
  int len=ups-&gt;size();
  </code></pre>
  <p>What is confusing to me is that in this line</p>
  <pre><code>unique_ptr&lt;int&gt; uptr (new int(3));
  </code></pre>
  <p>We use integer as an argument (between round brackets) and here</p>
  <pre><code>unique_ptr&lt;double&gt; uptr2 (pd);
  </code></pre>
  <p>we used an pointer as an argument. Does it make any difference?</p>
  <p>What is also not clear to me, is how pointers, declared in this way will be different from the pointers declared in a &quot;normal&quot; way.</p>