i am trying to build some wrapper around Glib::Dispatcher to dispatch any functional type into the dispatcher. I want to have some function dispatch that can transfer a function into the Glib main loop:
template<class Function, class ...Args>
std::future<typename std::result_of<Function(Args...)>::type>
dispatch(Function &&f, Args &&...args);
This function would create a packaged task from f(args) and return its future:
std::packaged_task<typename std::result_of<Function(Args...)>::type()> task(f(args...));
return task.get_future();
I need to create now from this task a std::packaged_task<void()>
to put them into one std::queue so that the connected function to Glib::Dispatcher can execute them.
My question is: How can i create from a std::packaged_task<R()>
a std::packaged_task<void()>
in two steps, so that i can return from the first task its future and put the second one into a queue of std::queue<std::packaged_task<void()>>
type?