title: How overload resolution decides the best between type and substituted type?
body: <p>I have example that works, but I believe it should not</p>
  <pre><code>template &lt;typename T&gt;
  void foo(int n) {
      std::cout &lt;&lt; &quot;foo(int)&quot; &lt;&lt; std::endl;
  }
  
  template &lt;typename T&gt;
  void foo(T t) {
      std::cout &lt;&lt; &quot;foo(T)&quot; &lt;&lt; std::endl;
  }
  
  int main() {
    foo&lt;double&gt;(42.0); // 1
    foo&lt;int&gt;(42);      // 2
  }
  </code></pre>
  <p><a href="https://godbolt.org/z/sbKd4z" rel="nofollow noreferrer">Live example on Godbolt</a></p>
  <p>For (1) everything is ok, exact template match beats standard conversion double -&gt; int</p>
  <p>But for (2) resulting instantiation looks equivalent for both overloads, and I expected error in this case</p>
  <p>Still both clang 11 and gcc 10.2 agree that best match for (2) is foo(int), so looks like I don't understand something important</p>