Re: ambiguous function call



"Mycroft Holmes" wrote:
the following code works in gcc, but not in VC8.0(SP1). Empirical evidence suggests that visual studio is right (both Comeau and the Intel compiler reject it), but I can't understand why the code should be ambiguous: x is a reference to array, so an exact match should be preferred to decay-into-pointer.
Can somebody help me understand?
Thanks,
MH


template <typename T>
void do_it_impl(const T* const x)
{
}

template <typename T, int K>
void do_it_impl(T (&x)[K])
{
}

template <typename T>
void do_it(T& x)
{
do_it_impl(x);
}

int main()
{
double a[30];
do_it(a);
}

Array-to-pointer conversion has the same rank as exact type match where no conversion is required. Hence the ambiguity. See "13.3.3.1.1 Standard conversion sequences (Table 9)" subclause in The Standard.

Alex

.



Relevant Pages