I've obtained a function pointer at run-time, let's say through something like GetProcAddress (so a weakly-typed void*), and then I've got this metadata that tells me what the function's signature is at run-time. How can I call the function correctly, preferably in Standard code? C++0x solution is fine, and I don't mind having to enforce my own type-safety.
1 Answer
Er... no, you can't. There is no thing like reflection is C++ or C++0x, you can't get a type out of a string or whatever. Unfortunately :)
3 Comments
JAB
If there are limits to the function signatures, though, and he knows what the specific possibilities are, couldn't he parse the metadata and cast the function pointer to a specific (possibly overloaded) function based on that?
Puppy
@JAB: I'd have to generate all possible overloads before-hand, which could be millions of permutations or more.
DangerMouse
It is possible to do - that's what Excel does when it calls XLLs. But you might need to resort to assembler to do it.