I have a vector of function pointers (void (*)()
) representing a list of actions you have already taken. How could I pop out the last two and make it into one function pointer and put it back in the list?
Example:
void link_last_two(std::vector<void (*)()> actions) {
if(actions.size() <= 1) return;
void (*first)() = actions.back();
actions.pop_back();
void (*second)() = actions.back();
actions.push_back([](){first(); second();});
}
Aucun commentaire:
Enregistrer un commentaire