Topic: conversion: ptr to member -> ptr to base of member
Author: "Markus Schaaf" <m.schaaf.exp-jun2001@gmx.de>
Date: Sun, 29 Apr 2001 10:09:25 GMT Raw View
"Hans Aberg" <remove.haberg@matematik.su.se> wrote:
> See the thread "Polymorphic function pointers" for a reply.
Thank you for giving any hint at all. Maybe a message-id would
have helped me more. There is no thread with this subject on the
server I'm using. Google couldn't find anything useful either.
---
[ 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.research.att.com/~austern/csc/faq.html ]
Author: "Markus Schaaf" <m.schaaf.exp-jun2001@gmx.de>
Date: Sun, 29 Apr 2001 18:33:07 GMT Raw View
"Markus Schaaf" <m.schaaf.exp-jun2001@gmx.de> wrote:
> > GACK. The fact that a cast is necessary here is a big tipoff. There's
> > no guarantee that this works. Pointer to derived member is not necessarily
> > convertable to pointer to base member.
>
> That's a shame. It seems to me that this conversion is always
> possible. Am I missing something? Is this simply an omission
> in the standard or are there actually reasons to do so?
I'm sorry. I hadn't read the thread, but only these 3 sentences I've
quoted first and got them wrong. The thing I am thinking about is
the following:
struct B {};
struct D : B {};
struct A { D d; };
...
typedef B A::*PAB;
typedef D A::*PAD;
PAB p = &A::d; // need not work, but would be nice to have
PAD q = static_cast< PAD >( p ); // this one too
---
[ 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.research.att.com/~austern/csc/faq.html ]