title: Calling template function without <>; type inference
body: <p>If I have a function template with <code>typename T</code>, where the compiler can set the type by itself, I do not have to write the type explicitly when I call the function like:</p>
  
  <pre><code>template &lt; typename T &gt; 
  T min( T v1, T v2 ) {
     return ( v1 &lt; v2 ) ? v1: v2;
  }
  int i1 = 1, i2 = 2; int i3 = min( i1, i2 ); //no explicit &lt;type&gt; 
  </code></pre>
  
  <p>But if I have a function template with two different typenames like:</p>
  
  <pre><code>template &lt; typename TOut, typename TIn &gt;
  TOut round( TIn v ) {
     return (TOut)( v + 0.5 );
  }
  double d = 1.54;
  int i = round&lt;int&gt;(d); //explicit &lt;int&gt;
  </code></pre>
  
  <p>Is it true that I always have to specify at least 1 typename? I assume the reason is because C++ can not distinguish functions between different return types.</p>
  
  <p>But if I use a void function and handover a reference, again I must not explicitly specify the return typename:</p>
  
  <pre><code>template &lt; typename TOut, typename TIn &gt; 
  void round( TOut &amp; vret, TIn vin ) {
     vret = (TOut)(vin + 0.5);
  }
     double d = 1.54;
     int i; round(i, d); //no explicit &lt;int&gt;
  </code></pre>
  
  <p>Should the conclusion be to avoid functions with return and more prefer <code>void</code> functions that return via a reference when writing templates? Or is there a possibility to avoid explicitly writing the return type? Something like "type inference" for templates. Is "type inference" possible in C++0x?</p>