Article View: comp.std.c++
Article #3084operator T* ambiguities
From: Michael Cook
Date: Tue, 23 Jan 1996 18:21
Date: Tue, 23 Jan 1996 18:21
27 lines
1480 bytes
1480 bytes
Does the standards committee consider this code ambiguous:
struct X;
struct Y
{
operator X*();
operator const X*() const;
};
void* f(Y y)
{
return y; //10
}
A couple compilers (different vendors) say it /is/ ambiguous, but I can't see
why. Shouldn't the compiler decide that `y.operator X*()' is a better choice
because `y' is not `const'--just as for other overload resolution?
(In particular, gcc says
x.C:10: ambiguous conversion from `Y' to `void *'
x.C:10: candidate conversion functions include `const X *' and `X *'
.)
Michael.
---
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID:
<r47myjasnx.fsf@erawan.cognex.com>Path:
arc1-ca.pugleaf.net!fido.asd.sgi.com!austernShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern From: Michael Cook <mcook@cognex.com> Newsgroups: comp.std.c++ Subject: operator T* ambiguities Date: 23 Jan 1996 10:21:32 PST Organization: Cognex Corporation, Natick, Massachusetts Approved: austern@isolde.mti.sgi.com Message-ID: <r47myjasnx.fsf@erawan.cognex.com> NNTP-Posting-Host: isolde.mti.sgi.com X-Original-Date: 23 Jan 1996 09:32:02 -0500 X-Newsreader: September Gnus v0.26/Emacs 19.29 X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBMQUnREy4NqrwXLNJAQH5ZwIAy1IN19JyYK2cOfBMsm4xbygLpTCPHDpa XkO/UTy9bKFUGszrwzzh3GDTBQ9eWm7xJ4XwETLcIZnosrf/obNU0w== =Ie1u Originator: austern@isolde.mti.sgi.com