Topic: Derived* to Base* vs Derived* to bool conversion (DR)
Author: Valentin Bonnard <Bonnard.V@wanadoo.fr>
Date: 1999/06/26 Raw View
Alexander Belopolsky wrote:
> class A {};
>
> class B : public A{};
> g++ prefers B* to A* conversion and prints "base",
>
> CC on the other hand picks f(bool) and prints "bool".
>
> According to Table 9 in 13.3.3.1.1 both conversions
> have "Conversion" rank. Pointer conversions are listed
> before boolean, but there is nothing in the text to say
> that the order in Table 9 is significant within the rank.
I just reread the text, and at first I got the impression
that the FDIS made it ambiguous (which would be plain wrong).
Of course g++ is correct. Why ? A way to think about it
is to define rank:
enum rank {
conversion,
promotion,
exact_match
};
then to say that operator< (rank, rank) is overloaded
to take into account the conversion which takes place
(which isn't even passed as argument).
Conclusion: sloppy wording (some would says nonsensical
presentation). I will submit this as defect (editorial).
--
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 ]