473,511 Members | 16,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to devise function pointer type from function name?

Hi,

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, falseval(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.
Sep 12 '08 #1
1 1552
Nitin wrote:
I have function:
exertn “C” void xmlFreeDoc(xmlDocPtr cur);
I want something like following:
typeof(xmlFreeDoc) functionpointer = xmlFreeDoc;
With the upcoming C++ standard you will be able to do it like this:

decltype(smlFreeDoc) functionpointer = xmlFreeDoc;

Or in this specific case, more easily:

auto functionpointer = xmlFreeDoc;

(decltype is still useful for some cases, where you need the type
itself, rather than just to create a variable.)
Sep 12 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

58
10049
by: jr | last post by:
Sorry for this very dumb question, but I've clearly got a long way to go! Can someone please help me pass an array into a function. Here's a starting point. void TheMainFunc() { // Body of...
27
2442
by: Marlene Stebbins | last post by:
I am experimenting with function pointers. Unfortunately, my C book has nothing on function pointers as function parameters. I want to pass a pointer to ff() to f() with the result that f() prints...
26
4823
by: aruna.mysore | last post by:
Hi all, I have a specific problem passing a function pointer array as a parameter to a function. I am trying to use a function which takes a function pointer array as an argument. I am too sure...
10
3564
by: Richard Heathfield | last post by:
Stephen Sprunk said: <snip> Almost. A function name *is* a pointer-to-function. You can do two things with it - copy it (assign its value to an object of function pointer type, with a...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7423
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7510
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5066
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.