title: GCC and Clang template call resolution differences
body: <p>Given the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  struct Alice
  {
    template &lt;typename A&gt;
    void operator|(const A&amp; /*a*/) const
    {
      std::cout &lt;&lt; "operator| member" &lt;&lt; std::endl;
    }
  };
  
  template &lt;typename A&gt;
  void operator|(const A&amp; /*a*/, const Alice&amp; /*alice*/)
  {
    std::cout &lt;&lt; "operator| non-member" &lt;&lt; std::endl;
  }
  
  int main()
  {
    Alice a;
    Alice b;
  
    a | b;
  
    return 0;
  }
  </code></pre>
  
  <p>It compiles without warning with both GCC 4.8.1, 4.9 and clang 3.4, but gives different results.</p>
  
  <pre><code>$ g++ -Wall -Wextra -std=c++11 alice.cpp &amp;&amp; ./a.out
  operator| non-member
  
  $ clang++ -Wall -Wextra -std=c++11 alice.cpp &amp;&amp; ./a.out
  operator| member
  </code></pre>
  
  <p>What causes this difference? How can I force the same behaviour?</p>
  
  <p><strong>EDIT:</strong> Interesting fact: removing the <code>const</code> qualifier from the member function makes gcc prefer the member function also. It does not solve the problem, however.</p>
  
  <p><strong>EDIT:</strong> clang++ prefers the non-member instead, if <code>-std=c++11</code> is not specified.</p>
  
  <p><strong>EDIT:</strong> ICC 14.0 prefers non-member, no warning emitted.</p>