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--
A smaller example:
This won't compile because func() is in A not B, but B is passed in as T
in useMethPtr():
class A {
public:
template<class T> void useMethPtr() {
void(T::* fp)() = &T::func;
}
void func() { }
};
class B : public virtual A {
public:
B() {
A::useMethPtr<B>();
}
};
VobjectBase uses the class name template parameter both for the typeid
string and for the class that the handler method is in. In my case I
want them to be different classes (because the handler method is in a
different class than the final MetaObject instance's class). I.e.
something like
class Base {
protected:
template<class MetaObjectClass> void registerMessageHandlers() {
VobjectBase::addMessageHandler<MetaObjectClass, Base>("message",
&Base::handleMessage);
}
void handleMessage(Message *m) { }
};
class Derived : public virtual Base, MetaObject {
public:
Derived() {
registerMessageHandlers<Derived>();
}
};
Maybe?
_______________________________________________
vos-d mailing list
[email protected]
http://www.interreality.org/cgi-bin/mailman/listinfo/vos-d