title: Why can't a smart pointer call new() for me in its constructor?
body: <p>Is it possible to write a smart pointer which allocates the object itself in its constructor - instead of the developer having to call <code>new</code>?  In other words, instead of writing:</p>
  
  <p><code>std::unique_ptr&lt;myClass&gt; my_ptr(new myClass(arg1, arg2))</code></p>
  
  <p>...one could write:</p>
  
  <p><code>std::smarter_ptr&lt;myClass&gt; my_ptr(arg1, arg2)</code></p>
  
  <p>Is the language syntax capable of expressing this?  Would this be desirable?  Hideous?  I'm thinking in particular of protecting against this mistake (which I've made myself, of course):</p>
  
  <p><code>myFunction(std::unique_ptr&lt;myClass&gt;(new myClass()), std::unique_ptr&lt;myClass&gt;(new myClass()))</code></p>
  
  <p>...which risks leaking whichever object is allocated first if the second allocation happens and throws before the first object is safely ensconced in its smart pointer.  But would a smarter pointer actually make this safe?</p>