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?
>
> Oh well. Looks like you might just have to add a message-handler stub in
the
> derived class that calls the base class or something, then use Peter's
> method for registering it.

Actually I guess this is the relevent section
http://www.kuzbass.ru:8086/docs/isocpp/expr.html#expr.cast (point -7-)

Same deal though.

-Ken


_______________________________________________
vos-d mailing list
[email protected]
http://www.interreality.org/cgi-bin/mailman/listinfo/vos-d

Reply via email to