title: order of functions in Variadic templates
body: <p>The following code is working! But my question is theoretical if we inverse the two version of <code>index_of</code> in the namespace detail, the compiler says that no function template is matching but why?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  
  template &lt;typename... Args&gt;
  class Pack{
  public:
    Pack(){}
  };
  
  template &lt;typename T, typename Arg, typename... Args&gt;
  bool contains(Pack&lt;Arg, Args...&gt; p)
  {
    Pack&lt;Args...&gt; n;
    return std::is_same_v&lt;T,Arg&gt; || contains&lt;T&gt;(n);
  }
  
  template &lt;typename T&gt;
  bool contains(Pack&lt;&gt; p){
    return false;
  }
  
  namespace detail{
  
  
    template &lt;typename T&gt;
    int index_of(Pack&lt;&gt; p, int index){
      return -1;
    }
  
    template &lt;typename T, typename Arg, typename... Args&gt;
    int index_of(Pack&lt;Arg, Args...&gt; p, int index = 0){
      if(is_same_v&lt;T,Arg&gt;) return index;
      Pack&lt;Args...&gt; rest;
      return index_of&lt;T&gt;(rest, index+1);
    }
  
  }
  
  template &lt;typename T, typename... Ts&gt;
  int index_of(Pack&lt;Ts...&gt; p)
  {
    return detail::index_of&lt;T&gt;(p);
  }
  
  int main()
  {
    Pack&lt;int,string,double&gt; p;
    cout &lt;&lt; contains&lt;int&gt;(p) &lt;&lt; endl;
    cout &lt;&lt; contains&lt;char&gt;(p) &lt;&lt; endl;
    cout &lt;&lt; index_of&lt;int&gt;(p) &lt;&lt; endl;
  }
  </code></pre>