I was trying to write a straightforward solution to this question: array decay to pointer and overload resolution
Clearly in the original, both overloads have equal conversion strength (exact match), so the non-template is preferred. Indeed, if I change the other to a template, the call become ambiguous:
struct stg
{
template<typename T = void>
stg(const char* const& c_str, T* = 0);
template<int N>
stg(const char (&str) [N]);
};
So I wanted to introduce a user-defined conversion, which would be strictly worse than the exact match of the second overload.
struct stg
{
template<typename> struct cvt { operator int() { return 0;} };
template<typename T = void>
stg(const char* const& c_str, int = cvt<T>());
template<int N>
stg(const char (&str) [N]);
};
But g++ says this is still ambiguous. Why does the user-defined conversion in the default argument not affect overload ranking?