title: Matching a tag with default not doing what I expect
body: <p>I was writing a function with an iterator tag to deal with different iterators.  However, I wanted to make a fallback, so used a template.  I would have expected that the template would have a lower precedence match then conversion to a base type.  I was wrong:</p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iterator&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  void test(std::forward_iterator_tag) {
    cout &lt;&lt; &quot;forward_iterator_tag&quot; &lt;&lt; endl;
  }
  void test(std::random_access_iterator_tag) {
    cout &lt;&lt; &quot;random_access_iterator_tag&quot; &lt;&lt; endl;
  }
  template &lt;typename TAG&gt;
  void test(TAG x) {
    cout &lt;&lt; &quot;other tag&quot; &lt;&lt; endl;
  }
  
  int main(){
    test(bidirectional_iterator_tag{});
    return 0;
  }
  </code></pre>
  <p>I would have expected that this program would print out <code>forward_iterator_tag</code>, but instead it matched on <code>other tag</code>.</p>
  <p>I was trying to make sense of this by reading <a href="https://en.cppreference.com/w/cpp/language/overload_resolution#Best_viable_function" rel="nofollow noreferrer">Best viable function</a>, but I didn't actually see (or maybe I just didn't understand) that which would say which would be taken first.  Thinking about this more I realize I can use the <code>...</code> parameter instead of a template as the ellipsis parameter has the lowest priority, but I would like to understand what is going on here and why.</p>