title: Why can't I have an auto_ptr in an Exception class
body: <p>I have a problem with auto_ptr in Exception classes, that I eventually reduced to:</p>
  
  <pre><code>#include &lt;memory&gt;
  
  class MyException
  {
      std::auto_ptr&lt;int&gt; m_foo2;
  };
  
  int main()
  {
      try
      {
          throw MyException();
      }
      catch (const MyException&amp;)
      {
  
      }
      return 0;
  }
  </code></pre>
  
  <p>This fails to compile with:</p>
  
  <blockquote>
    <p>/perforce/unstable/test/Common/Exceptions/TestException4.cpp: In
    function 'int main()':
    /perforce/unstable/test/Common/Exceptions/TestException4.cpp:12:
    error: no matching function for call to
    'MyException::MyException(MyException)'
    /perforce/unstable/test/Common/Exceptions/TestException4.cpp:4: note:
    candidates are: MyException::MyException()
    /perforce/unstable/test/Common/Exceptions/TestException4.cpp:4: note: 
    MyException::MyException(MyException&amp;)
    /perforce/unstable/test/Common/Exceptions/TestException4.cpp:12:
    error:   in thrown expression</p>
  </blockquote>
  
  <p>And the error goes away if I remove the auto_ptr.</p>
  
  <p>Is this because the exception is being copied or assigned? Is there a way of using <code>auto_ptr</code>s in an Exception?</p>