Re: ambiguous function call
- From: "Alex Blekhman" <xfkt@xxxxxxxxx>
- Date: Fri, 30 Mar 2007 14:48:07 +0300
"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
.
- Follow-Ups:
- Re: ambiguous function call
- From: Mycroft Holmes
- Re: ambiguous function call
- References:
- ambiguous function call
- From: Mycroft Holmes
- ambiguous function call
- Prev by Date: Re: Use DLL for get Windows Message?
- Next by Date: Re: ShellExecute not working in C++ 2005
- Previous by thread: ambiguous function call
- Next by thread: Re: ambiguous function call
- Index(es):
Relevant Pages
|