What is the approach to have a vector to schedule method calls of a class. I would like to have a vector of methods, something like this:
class Model {
using task_t = std::function<void()>;
std::vector<std::vector<task_t>> _frameTasks;
void add_function() { _frameTasks[3].push_back(&(this->function()); }
void function() {std::cout << "hi"; }
void step() {
for (auto task : _frameTasks[3]) task();
}
}
But the compiler complains that:
error: ISO C++ forbids taking the address of a bound member function to form a pointer to member function.
How could I solve this issue or what is the right approach?