title: Value-initializing an automatic object?
body: <p>I'm writing a template class and at one point in my code would like to be able to value-initialize an object of the parameterized type on the stack.  Right now, I'm accomplishing this by writing something to this effect:</p>
  
  <pre><code>template &lt;typename T&gt; void MyClass&lt;T&gt;::doSomething() {
      T valueInitialized = T();
      /* ... */
  }
  </code></pre>
  
  <p>This code works, but (unless the compiler is smart) it requires an unnecessary creation and destruction of the temporary <code>T</code> object.  What I'd like to write is the following, which I know is incorrect:</p>
  
  <pre><code>template &lt;typename T&gt; void MyClass&lt;T&gt;::doSomething() {
      T valueInitialized(); // WRONG: This is a prototype!
      /* ... */
  }
  </code></pre>
  
  <p>My question is whether there is a nice way to value-initialize the automatic object without having to explicitly construct a temporary object and assign it over to the automatic object.  Can this be done?  Or is <code>T var = T();</code> as good as it gets?</p>