By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,148 Members | 1,285 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,148 IT Pros & Developers. It's quick & easy.

C++ template function problem, reply is appreciate!

P: n/a
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.

Jun 10 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
linarin wrote:
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
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 11 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.