我有
template <void (*T)(Entity *), typename Caller>
class Updater
{
public:
Updater(Caller c):m_caller(c){}
void process(Entity * e)
{
(m_caller->*T)(e); //Is this right?
}
private:
Caller m_caller;
};
我知道我可以像这样实例化它
Foo f;
Updater<&Foo::Bar> updater(&f);
假设Foo
有
void Foo::Bar(Entity *e);
但是如果它有所需的方法怎么办?像这样
template <typename T>
void Bar(T t);
我应该如何实例化它?像这样:?
Foo f;
Updater<&Foo::Bar<Entity *>> updater(&f);
当我在我的真实代码中这样做时,我得到
invalid template argument for ..., expected compile-time constant expression
所以2个问题:
1、(m_caller->*T)(e);
正确吗?如果不是,我怎么叫它?
2、如何实例化它?