Article View: comp.std.c++
Article #1341Argument Matching
From: Martin Hitz
Date: Wed, 26 Jun 1991 13:30
Date: Wed, 26 Jun 1991 13:30
36 lines
1523 bytes
1523 bytes
I have been looking for an example for the usefulness of the
"strictly better match" rule in the context of overloading resolution.
The ARM gives one on pages 314-315 (section 13.2), however, I am wondering
if it was possible to rewrite it in a "class-free" manner.
I came up with the following:
int f(void*, void*); // =: 1
int f(const int*, int*); // =: 2
int f(int *, const int*); // =: 3
int i = f(0,0);
The best match sets are {1,3} for the first, and {1,2} for the second argument.
The intersection is {1} (unique), however, 1 is NOT a strictly better match
than 2 (therefore, the call is illegal), because (comparing 1 to 2):
0 -> void* is considered equal to 0 -> const int*
0 -> void* is considered equal to 0 -> int*
although
0 -> int* is considered BETTER to 0 -> const int*
during the first step (computation of "best" match sets).
I have two questions:
1) Is the example valid?
if yes: 2a) Is the argumentation correct?
if no: 2b) Is there a valid "class-free" example?
Thank you!
Martin Hitz@csi.uottawa.ca
Technical Details
Message-ID:
<1991Jun26.133009.19352@csi.uottawa.ca>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!cunews!csi.uottawa.ca!newsShow Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!utzoo!utgpu!cunews!csi.uottawa.ca!news From: hitz@csi.uottawa.ca (Martin Hitz) Subject: Argument Matching Message-ID: <1991Jun26.133009.19352@csi.uottawa.ca> Summary: Need help Keywords: Argument Matching, overloading resolution, strictly better match Sender: news@csi.uottawa.ca Nntp-Posting-Host: sim5 Organization: University of Ottawa Distribution: na Date: Wed, 26 Jun 91 13:30:09 GMT