title: Ambiguity between function and function in namespace with same argument
body: <p>Can anybody explain why there is an ambiguity between <code>A::f(const B&amp; b)</code> and <code>f(const A::B&amp; b)</code>. I consider the code to be quite explicit about the intention.</p>
  <pre><code>#include &lt;iostream&gt;
  
  namespace A
  {
    class B
    {
    protected:
      double value_;
    public:
      B() : value_(15.0) {}
      double getValue() const {return value_;}
    };
  
    void f(const B&amp; b)
    {
      std::cout &lt;&lt; &quot;f(b) = &quot; &lt;&lt; b.getValue() &lt;&lt; std::endl;
    }
  }
  
  void f(const A::B&amp; b)
  {
    std::cout &lt;&lt; &quot;Other f(b) = &quot; &lt;&lt; b.getValue() &lt;&lt; std::endl;
  }
  
  int main()
  {
    A::B b;
    A::f(b);
    f(b);
    return 0;
  }
  </code></pre>
  <p>However, both g++ 7.5.0 and clang 6.0.0 complain about ambiguous function call
  (<code>error: call of overloaded ‘f(A::B&amp;)’ is ambiguous</code>) regardless of compiler flags and optimizations.</p>