Topic: Converting from pointer to boolean
Author: Valentin Bonnard <bonnardv@pratique.fr>
Date: 1997/02/01 Raw View
Michael Greenberg wrote:
>
> My understanding (from april 95 draft) is that the following is ambiguous:
>
> class bar;
> foo(bool) ;
> foo(void*) ;
> void mumble(bar* b)
> {
> foo(b) ; // ambiguous
> }
>
> Is this [still] true?
>
> Assuming that it is, does it make sense to treat a
> conversion of a pointer to a void*
> as better than a
> conversion of a pointer to a bool?
>
> If not, that means it is not so useful (w/o using casts) to overload a
> function on void* and bool (i.e. operator<<)
That's not my understanding:
A* -> void* and A* -> bool are both std conversions with the same
rank (conversion) but 13.3.3.2.4 says:
--A conversion that is not a conversion of a pointer, or pointer to
member, to bool is better than another conversion that is such a
conversion.
So foo (void*) should be choosed.
--
Valentin Bonnard
mailto:bonnardv@pratique.fr
http://www.pratique.fr/~bonnardv (Informations sur le C++ en Francais)
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: mlg@scr.siemens.com (Michael Greenberg)
Date: 1997/01/27 Raw View
My understanding (from april 95 draft) is that the following is ambiguous:
class bar;
foo(bool) ;
foo(void*) ;
void mumble(bar* b)
{
foo(b) ; // ambiguous
}
Is this [still] true?
Assuming that it is, does it make sense to treat a
conversion of a pointer to a void*
as better than a
conversion of a pointer to a bool?
If not, that means it is not so useful (w/o using casts) to overload a
function on void* and bool (i.e. operator<<)
--
Michael Greenberg email: mgreenberg@scr.siemens.com
Siemens Corporate Research phone: 609-734-3347
755 College Road East fax: 609-734-6565
Princeton, NJ 08540
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]