title: Automatic template instantiation
body: <p>Given the class template</p>
  
  <pre><code>template&lt;class T&gt;
  struct A {
      A( const T &amp; x );
  };
  </code></pre>
  
  <p>I would like to instantiate objects of this class <em>without</em> writing out the actual type <code>T</code>, because this is typically a clumsy type resulting from some sort of expression templates and lambda functions.  One way to accomplish this would be</p>
  
  <pre><code>template&lt;class T&gt;
  A&lt;T&gt; create_A( const T&amp; t ){ 
      return A&lt;T&gt;( t );
  }
  
  int main(){
      auto a = create_A( complicated_expression );
  }
  </code></pre>
  
  <p>Here I never wrote the actual type of the expression, but this creates a copy of <code>A</code> and won't work without a copy constructor.  I don't have a copy (or move) constructor.  What I'm looking for is something like </p>
  
  <pre><code>A a( complicated_expression );
  </code></pre>
  
  <p>Clean and simple, and the compiler should be able to figure out the actual type.  Unfortunately this isn't valid C++.  So what would be the best valid C++ syntax to accomplish the same thing?  Currently I'm doing this:</p>
  
  <pre><code>auto x = complicated_expression;
  A&lt;decltype(x)&gt; a(x);
  </code></pre>
  
  <p>But this seems unnecessary verbose.  Is there a better way to do this?</p>