From 231538048130044141
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,991a11e8ea03ee36
X-Google-Attributes: gidf78e5,public
From: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Subject: Re: Overload resolution and references
Date: 1999/03/24
Message-ID: <36F919B0.6572@wanadoo.fr>#1/1
X-Deja-AN: 458568870
X-NNTP-Posting-Host: jonque.ens.fr
Content-Transfer-Encoding: 7bit
Approved: stephen.clamage@sun.com (comp.std.c++)
References: <36F7E144.23FA@smarts.com>
To: Jerry Leichter <leichter@smarts.com>
X-UID: 0000000001
X-Status: $$$T
Content-Type: text/plain; charset=us-ascii
Organization: Ecole Normale Superieure, Paris, France
Mime-Version: 1.0
Newsgroups: comp.std.c++
Originator: clamage@taumet


Jerry Leichter wrote:

> HP's aCC (missing the absolute latest set of patches, but I don't recall
> seeing any indication of a patch in this area) compiles the whole thing
> with no complaints.  The result produces the following output:

First let write down the viable functions:

> 26: u(i)-> u(int&)

Candidates are: u(int&), u(const int&)
But u(const int&) requires a qualification conversion (at least 
I think it's called qualification conversion), so this ok.

> 27: u(ci)-> u(const int&)

Candidates are: u(const int&)
ok

> 28: u(1)-> u(const int&)

Candidates are: u(const int&)
ok

> 32: v(i)-> v(const int&)
> 33: v(ci)-> v(const int&)
> 34: v(1)-> v(int)

For the above cases:
Candidates are: v(int), v(const int&)
They aren't comparable, so these calls are ambiguous.

> Lines 32 and 33 make sense if you assume a preference, in overloading,
> for a const ref T over a T.  This is a reasonable thing to do -

I disagree.

> certainly for class types - but I can't seem to find language to justify
> it.  Line 34, on the other hand, is a puzzle:  How does it differ from
> line 33? 

1 is an rvalue of type int, ci is a lvalue of type const int

(Note that g++ makes all these three cases ambiguous. :-)

> Can anyone explicate?

The rules were badly broken and changed recently.

-- 

Valentin Bonnard


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




