title: smart pointer - what if constructor throws?
body: <p>I have a class that connects to a USB device in the constructor. If the device isn't present or some other situation fails then the constructor throws an exception and the calling code deals with it.</p>
  
  <p>Something akin to:</p>
  
  <pre><code>CDevice* pDevice = NULL;
  try
  {
      pDevice = new CDevice();
  }
  </code></pre>
  
  <p>and so on. I would like to replace this call with an <code>auto_ptr</code> but am not clear how to trap the exception while maintaining the correct scope of the object. </p>