Sorry for the badly-worded title.
I've been looking through the documentation, but I cannot find anything that might solve this problem I have.
Basically I want to store several function1<void, void*>
, with arguments provided, in a vector, and then execute them at a later stage.
This is what I want to accomplish:
typedef boost::function1<void, void*> Task;
Vector<Task> mScheduledTasks;
int MyArg = 5;
void SomeTask(void* arg)
{
// ....
}
void AddSomeTasks()
{
// nevermind that MyArg is globally accessible
for (int i = 0; i<5; i++)
mScheduledTasks.push_back(boost::bind(&SomeTask, _1), (void*)&MyArg);
}
void ExecuteTask()
{
Task task = mScheduledTasks.front();
task();
}
Now executing task() it wants me to pass an argument, but I passed it in AddSomeTasks? Why is it not using that? Or I have missunderstod the usage of boost::bind?
Thanks