I tried to write a direct solution to this question: array decay to pointer and overload resolution
Obviously, in the original, both overloads have the same conversion power (exact match), so not the template is preferred. Indeed, if I change another template, the call becomes 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 custom transformation that 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 doesn't the custom conversion in the default argument affect the overload rating?