I would like to bind any kind of event to functions of any type for the (G)UI system of a game I am working on.
I would like to store any kind of functions and its initial arguments in a Functor template class, which I can bind to a signal binding index. Events bound to a signal binding will trigger it once they appear in the event queue, which will cause all Functors bound to this binding to be called.
I have found that the way to store the function arguments was to use an std::tuple in the functor template, but I need help initializing it correctly and unpacking it properly when calling the function.
This is what I have so far:
template<typename R, typename... Args>
class FuncBinding {
private:
    std::tuple<Args...> args;
    R(*fun)(Args...);
public:             
    FuncBinding(R(*pF)(Args...) , Args... pArgs) 
        :fun(pF), args(std::make_tuple<Args...>(pArgs)) {}
    R invoke() {
        return fun(args...);
    }
    R callFunc(Args... pArgs) {
        return fun(pArgs...);
    }
};
How do I use the parameter pack Args correctly in order to...
- ...create the template class std::tuple<Args...>appropiately
- ...initialize the std::tuple<Args...>instanceargswith the functor arguments
- ...unpack the tuple when calling the function through the function pointer R(*fun)(Args...)
 
    