I have a library with a function that accepts a function pointer and a parameter to give the function. I'm wrapping the thing in a class and so for each instance of the class I give it a function pointer to a private static dispatch function, and the parameter I give it is the this pointer. The dispatch function just calls the instance version of the function from the instance pointer given as a parameter. The issue is, when the class is destructed, it needs to remove that function-parameter pair from the functions-to-call list - but it only searches by function pointer and I cannot make it take a parameter to match with.
Is there a way I can create, at runtime, copies of the dispatch function so that the function pointers are unique? Or is there another solution?
I think, and I haven't used it for what you describe, but maybe if you can use boost for this, using boost::function and boost::bind you can get what you are looking for (I think).
Essentially boost::function acts like your function pointer, it doesn't buy you much on it's own, in your case.
Then when you use boost::bind you can pass up to 9 parameters for regular function and 8 for member functions (this-> is implicit). Your function pointer is essentially more than just a function pointer now. I think then you can use this to describe each classes search criteria. My usage and wording may be off, but I think it is possible using a variation of boost::bind and boost::function.
edit:
This may not be possible with the private functions, but I'm not sure
edit 2:
After further investigation this may be of use to you.
The library is hard coded to take a pointer-to-function, I'm not sure how to get that from boost, or if what I got would be unique from any other instance.
Nevermind, I misunderstood how it works. It calls the function once after I request it to, and then forgets about it. This makes my life much easier. Sorry for the hassle.