c++ function overloading with Exact Match
<p>Can someone explain why the overloading resolution will pick the 2nd function, instead of reporting an ambiguous error. Anyway, the 2nd function is an exact match, but the 1st undergoes a qualification conversion(from char*　to const char*). However, the document from <a href="http://en.cppreference.com/w/cpp/language/overload_resolution" rel="noreferrer">http://en.cppreference.com/w/cpp/language/overload_resolution</a><br>
states that qualification conversion is also an exact match, and hence both candidates should have same ranking.</p>

<blockquote>
  <p>Each type of standard conversion sequence is assigned one of three ranks:</p>
  
  <p>1) Exact match: no conversion required, lvalue-to-rvalue conversion, qualification conversion, function pointer conversion, (since C++17) user-defined conversion of class type to the same class</p>
  
  <p>2) Promotion: integral promotion, floating-point promotion</p>
  
  <p>3) Conversion: integral conversion, floating-point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, boolean conversion, user-defined conversion of a derived class to its base</p>
</blockquote>

<pre><code>void g(const char* x)
{
    std::cout &lt;&lt; "g(const char* x)" &lt;&lt; std::endl;
}

void g(char* x)
{
    std::cout &lt;&lt; "g(char* x)" &lt;&lt; std::endl;
}

void callg()
{
    char a[] = "sample";
    g(a);
}
</code></pre>