title: What is the rationale behind ADL for arguments whose type is a class template specialization
body: <p>I've spent some time trying to realize why my code doesn't compile and I've realized that in C++ <strong>Argument Dependent Lookup</strong> uses template typename arguments to determine name lookup scope.</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;string&gt;
  #include &lt;functional&gt;
  
  namespace myns {
  
      template&lt;typename T&gt;
      struct X
      {};
  
      template&lt;typename T&gt;
      auto ref(T) -&gt; void
      {}
  
  } // namespace myns
  
  auto main() -&gt; int
  {
      ref(myns::X&lt;int&gt;{});
      ref(myns::X&lt;std::string&gt;{}); // error: call to 'ref' is ambiguous
  }
  </code></pre>
  
  <p>So the former ref call compiles, because for <code>myns::X&lt;int&gt;</code> only <code>myns::ref</code> is considered, while the latter doesn't compile because it finds <code>myns::ref()</code> as well as <code>std::ref</code></p>
  
  <p><strong>My question is</strong> how this can be useful? Why would I need this? Do you have any ideas, examples? For now I can only see drawbacks like in the example above, where it introduces unneeded ambiguity.</p>