Topic: operator T* amibiguities
Author: clamage@Eng.Sun.COM (Steve Clamage)
Date: 1996/01/17 Raw View
In article fsf@erawan.cognex.com, Michael Cook <mcook@cognex.com> writes:
>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.
The ARM (and early versions of the C++ draft standard) said that any
data pointer type could be converted implicitly to void*. Under that
rule, the code is ambiguous.
That rule also allows silent loss of the const qualifier, which is wrong.
The rule was changed so that there is no implicit conversion to void* from
a cv-qualified pointer. Under the new rule, the code is not ambiguous, and
the conversion to X* would be selected.
---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ 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. ]