title: Why does SFINAE only apply to one of these two seemingly identical functions?
body: <p>The following code does not compile (With clang 7.0, --std=c++17):
  </p>
  
  <pre><code>struct Foo {
      void foo() {}
  };
  struct Bar {
      void bar() {}
  };
  struct Both {
      void foo() {}
      void bar() {}
  };
  
  template &lt;typename T, typename&gt;
  void DoStuff(T input) {
      input.foo();
  }
  
  template &lt;typename T, typename...&gt;
  void DoStuff(T input) {
      input.bar();
  }
  
  int main(int argc, char** argv) {
      DoStuff(Foo());
      return 0;
  }
  </code></pre>
  
  <p>The error is:</p>
  
  <pre class="lang-none prettyprint-override"><code>&lt;source&gt;:19:11: error: no member named 'bar' in 'Foo'
      input.bar();
      ~~~~~ ^
  
  &lt;source&gt;:23:5: note: in instantiation of function template specialization 'DoStuff&lt;Foo&gt;' requested here
      DoStuff(Foo());
  </code></pre>
  
  <p>However, if you change <code>Foo()</code> to <code>Bar()</code> (or <code>Both()</code>) it compiles just fine. In the <code>Bar()</code> case, this shows that SFINAE is taking effect; in the <code>Both()</code> case it shows that the <code>typename...</code> overload has lower precedence, so the other one is chosen when both apply.</p>
  
  <p>But what I don't understand is why SFINAE applies to the <code>Bar()</code> case but not the <code>Foo()</code> case?</p>