title: How can this return type be determined at compile-time?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8195150/why-is-this-min-template-of-cpp-next-at-fault">Why is this &ldquo;min&rdquo; template of cpp-next at fault?</a>  </p>
  </blockquote>
  
  
  
  <p>From another question I got this function template:</p>
  
  <pre><code>template &lt;class T, class U&gt;
  auto min(T x, U y) -&gt; decltype(x &lt; y ? x : y) {
      return x &lt; y ? x : y;
  }
  </code></pre>
  
  <p>It compiles and seems to work fine, but I'm unsure why it works. How can the return type be deduced at compile-time? &mdash; I would think it can be either <code>T</code> or <code>U</code> depending on which argument is smaller, and that can only be determined at run-time.</p>