struct taskinfo{
template <class callable, class... arguments>
taskinfo(callable&& f, arguments&&... args){
std::function<typename std::result_of<callable(arguments...)>::type()> task(std::bind(std::forward<callable>(f), std::forward<arguments>(args)...));
}
};
void test2(int a)
{
printf("%i\n", a);
return;
}
int main()
{
taskinfo t1(&test2,100);
std::priority_queue<taskinfo> tasks;
tasks.push(t1);
//tasks.top(). Execute task
return 0;
}
I need to execute tasks by popping out of priority queues. My goal is to have a structure with function with any return type and accepting variable arguments.
Aucun commentaire:
Enregistrer un commentaire