vector of function objects
Hi all, I want to be able to do this:
Code:
std::vector<???> vec;
vec.push_back(boost::bind(&testClass::run,t));
vec.push_back(boost::bind(&testfunc));
for(int i = 0; i <vec.size(); ++i) // invoke all function objects in vec...
{
vec[i]();
}
How do i accomplish this? All functions objects is invoked in the same way by the operator () but I have no idea how I make a vector of such objects, I tried first with a void (*)() but of course didn't it work, as I thought :( I have one ugly solution and it is to make a abstract class and then make a virtual method and use polymorphism.
Thanks in advance.