I've seen parts of this answered however I'm unsure how a complete solution would look like, I apologize, but I don't really understand parameter packs, and how they relate to tuple.
Here's bits of my code that I'm trying to make work together:
I have this which is basically just calling the function, I think this can be used to save the call into the "callable" structure, to make an interface.
from this question:
C++ generic function call with varargs parameter
template
auto call(R(*function)(Args...), Args... args) -> typename std::enable_if::value, R>::type {
return function(args...);
}
template
void call(void (*function)(Args...), Args... args) {
function(args...);
}
And this structure which should store the parameters and the function pointer. (thanks to RaymondChen for pointing out how it should be correctly)
template
struct callable
{
R(*function)(Args...);
std::tuple params;
callable(Args... argv):
params(std::make_tuple(argv...))
{}
};
I'm still unsure how I would actually call back the function with the tuple, as far as I understand I should somehow turn the tuple back to Args... and then simply call it.
What I'm trying to achieve:
* Save a call to be used later on
* Create my own call and fill it with my own parameters, from a running app.
* Read out saved parameters to do some manner of debugging.
0 comments:
Post a Comment
Thanks