jimad@microsoft.UUCP (Jim ADCOCK) (12/06/90)
Can someone clarify for me the resolution of overloaded functions of
with array reference arguments? Seems to me that ARM says that
arrays do not suffer their common automatic conversion to a pointer to
their first element when assigned to a same-typed reference,
thus in the example below the three overloaded functions should be
called in turn, via a first level, "best match" trivial conversion
of a type to a reference to the same type? [But when I tried this on two
different compilers they both did strange, and differing things.]
This questions relates to my still trying to understand whether arrays
in C++ are exact types or not. My understanding is that are arrays in
C++ are [typically] exact types, that suffer auto-conversion to inexact type
[pointer to first member] in all "Classic C" schenerios, but not in
C++ -only schenerios?
#include <stdio.h>
typedef int V1[1];
typedef int V2[2];
typedef int V3[3];
extern int printf(const char*, ...);
void f(V1&) { printf("f(V1&)\n"); }
void f(V2&) { printf("f(V2&)\n"); }
void f(V3&) { printf("f(V3&)\n"); }
int main(int argc, char* argv[])
{
V1 v1;
V2 v2;
V3 v3;
f(v1);
f(v2);
f(v3);
return 0;
}