Topic: Fwd: pointer to member conversion to a pointer to member that is a
Author: hyrosen@mail.com (Hyman Rosen)
Date: Fri, 20 Aug 2004 22:51:11 GMT Raw View
Victor Bazarov wrote:
> The basic idea is: if for two classes B and D exists an implicit
> conversion from { D* to B* } (plain vanilla ptr-to-derived to ptr-to-base
> conversion, see 4.10), then the conversion { D T::* to B T::* } for an
> arbitrary class T should exist as well. I there anything I am missing?
When the converted pointer is called, there may need to be fixup code
generated to the D -> B conversion, so I don't think handling this is
particularly easy. Here's example code:
struct A { double a; };
struct B { unsigned b; };
struct AB : A, B { long ab; };
struct X { AB ab() { return AB(); } };
int main()
{
AB (X::*fab)() = &X::ab;
B (X::*fb)() = fab; // The suggested conversion
X x;
B b = (x.*fb)();
}
---
[ 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://www.jamesd.demon.co.uk/csc/faq.html ]