On Thu, 2007-03-15 at 23:39 -0700, Ken Taylor wrote:
> Ken Taylor wrote:
> > Reed Hedges wrote:
> > > Peter Amstutz wrote:
> > > > Try
> > > >
> > > >    template<class T> register() {
> > > >      VobjectBase::registerHandler<T>("message", &T::handler);
> > > >    }
> > > >
> > > > (note T::handler)
> > >
> > > Same problem -- it can't use the method in the base class when the
> > > template parameter is the derived class--
> > >
> >
> > Could you use casting to make the compiler happy? Something like:
> >
> >   template<class T> register() {
> >     VobjectBase::registerHandler<T>("message", ( void (T::*)(Message*) )
> > &handler);
> >   }
> >
> > ... it should be safe to cast a pointer-to-base-class-member down to a
> > pointer-to-derived-class-member. Maybe a dynamic_cast is necessary instead
> > (especially in the case of a virtual derived class)? But I'm too lazy to
> > actually test any of this out right now ;)
> >
> 
> http://www.kuzbass.ru:8086/docs/isocpp/conv.html#conv.mem
> 
> Ick... it looks like you can't do this conversion with virtual inheritance
> :/
> 
> What the hell? If member function pointers are smart enough to resolve
> virtual functions, then why couldn't they resolve virtual inheritance, given
> that there's enough information to recognize that it's virutal inheritance
> at compile-time?

Because recognizing that virtual inheritance is involved is the extent
of what can happen at compile time. Introducing virtual inheritance
means that the class layout cannot be resolved at compile time. The
(somewhat) more familiar consequence of this is that dynamic_cast must
be used to downcast from a virtual base (rather than static_cast, which
is sufficient for nonvirtual bases).

-- 
Braden McDaniel                           e-mail: <[EMAIL PROTECTED]>
<http://endoframe.com>                    Jabber: <[EMAIL PROTECTED]>



_______________________________________________
vos-d mailing list
vos-d@interreality.org
http://www.interreality.org/cgi-bin/mailman/listinfo/vos-d

Reply via email to