C++ template function problem, reply is appreciate!

L

linarin

How could I make this templates to work:

template<typename F,F f> //here f is non type template parameter
bool MethodProxy(int a,int b){ //could'nt change this function
return type and arguments.
return true;
}

template<typename F> //here F is a type of function object
void Def(F f){
static MyStruct global_methods[] =
{
{ "alert", JsProxyMethod<F,f> }, // error occur at here
NULL
} ;
//here do more works.
}

int alert(int a){
return 0;
}

int main(int argc,char* argv[]){
Def(alert); //when this function invoked, alert will be
executed.
return 0;
}



the error message is :
compiler complains that "f" not a valid argument and JsProxyMethod is
not a external linkage function.
 
V

Victor Bazarov

linarin said:
How could I make this templates to work:

template<typename F,F f> //here f is non type template parameter
bool MethodProxy(int a,int b){ //could'nt change this function
return type and arguments.

There seems to be no use of 'F' or 'f' anywhere in this function. Are
you sure you need them?
return true;
}

template<typename F> //here F is a type of function object
void Def(F f){
static MyStruct global_methods[] =

What's 'MyStruct'?
{
{ "alert", JsProxyMethod<F,f> }, // error occur at here
NULL
} ;
//here do more works.
}

int alert(int a){
return 0;
}

int main(int argc,char* argv[]){
Def(alert); //when this function invoked, alert will be
executed.
return 0;
}



the error message is :
compiler complains that "f" not a valid argument and JsProxyMethod is
not a external linkage function.

I am not sure it's possible to help you without seeing _real_ code
that produces that error message.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,266
Latest member
DavidaAlla

Latest Threads

Top