🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Jim ADCOCK Thu, 06 Dec 1990 00:33
overloading and array reference arguments
#624
Author: Jim ADCOCK
Date: Thu, 06 Dec 1990 00:33
40 lines
1612 bytes
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;
}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads