C++ Can';t转换函数指针参数

C++ Can';t转换函数指针参数,c++,templates,function-pointers,v8,C++,Templates,Function Pointers,V8,我得到的错误是: error C2664: 'v8::FunctionTemplate::New' : cannot convert parameter 1 from 'v8::Handle<T> (__cdecl *)(const v8::Arguments &)' to 'v8::InvocationCallback' 错误C2664:'v8::FunctionTemplate::New':无法将参数1从'v8::Handle(_cdecl*)(const v8::Ar

我得到的错误是:

error C2664: 'v8::FunctionTemplate::New' : cannot convert parameter 1 from 'v8::Handle<T> (__cdecl *)(const v8::Arguments &)' to 'v8::InvocationCallback'
错误C2664:'v8::FunctionTemplate::New':无法将参数1从'v8::Handle(_cdecl*)(const v8::Arguments&')转换为'v8::InvocationCallback'
相关定义:

typedef Handle<Value> (*InvocationCallback)(const Arguments& args);




template<class C> class V8ScriptClass
{
public:
    template<class C, typename Rtype, typename Ptype1, Rtype (C::*FuncPtr)(Ptype1)> 
    void RegisterFunc(const char* const scriptname)
    {
        objtemplate->Set(
            v8::String::New(scriptname), 
            v8::FunctionTemplate::New(
            V8ScriptClass<C>::RelayCallback<C, Rtype, Ptype1, FuncPtr>
                ));
    };

template<typename Rtype, typename Ptype1, Rtype (*FuncPtr)(Ptype1 param1)>
static v8::Handle<v8::Value> RelayCallback(const v8::Arguments& args)
{
    std::cerr<<__FUNCTION__<<std::endl;
    v8::HandleScope handle_scope;
    return handle_scope.Close(toJSType( ((FuncPtr)(toCType(args[0]))) ));
};
typedef句柄(*InvocationCallback)(常量参数和参数);
模板类V8ScriptClass
{
公众:
模板
无效注册表函数(常量字符*常量脚本名)
{
对象模板->设置(
v8::String::New(脚本名),
v8::FunctionTemplate::新建(
V8ScriptClass::RelayCallback
));
};
模板
静态v8::Handle RelayCallback(常量v8::Arguments和args)
{

std::cerr我发现了错误。RelayCallback模板将静态函数指针作为参数,我尝试使用成员函数指针对其进行实例化。我只需将其更改为成员函数指针模板参数。

您在哪里使用InvocationCallback?添加了缺少的声明,而不仅仅是签名(=0是默认参数)但是实际的invocation.look inside RegisterFunc是FunctionTemplate::New构造函数,它接受一个函数指针参数。您到底在哪里得到错误?在实例化点,即您正在使用RegisterFunc的位置?否则,看起来编译器很混乱。您可以尝试使用类型名吗?RelayCallback仍然是注册表函数中的类型不完整。
class EXPORT FunctionTemplate : public Template {
 public:
  /** Creates a function template.*/
  static Local<FunctionTemplate> New(
      InvocationCallback callback = 0,
      Handle<Value> data = Handle<Value>(),
      Handle<Signature> signature = Handle<Signature>());