title: Sense of using std::auto_ptr
body: <p>What is the sense of <code>auto_ptr</code>?
  Look at this code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;memory&gt;
  
  class A
  {
  public:
      ~A()
      {
          std::cout &lt;&lt; "DEST";
      };
  };
  
  void func(A* pa)
  {
      std::cout &lt;&lt; "A pointer";
  }
  
  void test()
  {
      A a;
      std::auto_ptr&lt;A&gt; pA(new A);
      //func(pA);  //compiler error here cannot convert parameter 1 from 'std::auto_ptr&lt;_Ty&gt;' to 'A *' 
      std::cout &lt;&lt; "end";
  }
  
  int main(int argc, char* argv[])
  {
      test();
      return 0;
  }
  </code></pre>
  
  <p>What's the sense of using this <code>auto_ptr</code>?</p>
  
  <ul>
  <li>It calls the class destructor when getting out of scope as normal class initialize variable (a).</li>
  <li>I cant pass this pointer to a function with class pointer (func)</li>
  <li>I cant use pointer <code>auto_ptr</code> for <code>A[]</code> or <code>char[]</code> because auto_ptr calls delete not <code>delete[]</code>.</li>
  </ul>
  
  <p>The only think is that I dont have to write delete, but whats the sense of pointer if it will be destroyed when I get out of scope. I use pointer to control the live of the variable.</p>
  
  <p>The normal variable initialize is on the stack and pointer on heap, but tell me what is the sense of using the <code>auto_ptr</code> rather then normal pointer?</p>