How to devise function pointer type from function name? : c++
This is a discussion on How to devise function pointer type from function name? within the c++ forums in Programming Languages category; Hi All, Can I devise function pointer type from function name by using template programming? e.g. I have function: exertn “C” void xmlFreeDoc(xmlDocPtr cur); I want something like following: typeof(xmlFreeDoc) functionpointer = xmlFreeDoc; i.e value to type conversion I want pass this type to Holder which will call this function in dtor. Currently I am using following code to do the same task: extern "C" { typedef void (*funcPtr)(void*) ; } Holder<xmlChar, funcPtr, false> val(xmlNodeListGetString(doc, cur_node- >children, 1), xmlFree); Issues with above code: I need to add every type of function in the extern “C” block. Thanks, Nitin. -- [ ...
| c++ comp.lang.c++ usenet archive |
![]() |
| | LinkBack | Thread Tools |
|
#1
| |||
| |||
| Can I devise function pointer type from function name by using template programming? e.g. I have function: exertn “C” void xmlFreeDoc(xmlDocPtr cur); I want something like following: typeof(xmlFreeDoc) functionpointer = xmlFreeDoc; i.e value to type conversion I want pass this type to Holder which will call this function in dtor. Currently I am using following code to do the same task: extern "C" { typedef void (*funcPtr)(void*) ; } Holder<xmlChar, funcPtr, false> val(xmlNodeListGetString(doc, cur_node- >children, 1), xmlFree); Issues with above code: I need to add every type of function in the extern “C” block. Thanks, Nitin. -- [ See http://www.gotw.ca/resources/clcm.htm for info about ] [ comp.lang.c++.moderated. First time posters: Do this! ] |


