I have the following code that uses a for loop and I would like to use transform, or at least for_each instead, but I can't see how.
typedef std::list<boost::function<void(void) > CallbackList;
CallbackList callbacks_;
//...
for(OptionsMap::const_iterator itr = options.begin(); itr != options.end(); ++itr)
{
callbacks_.push_back(boost::bind(&ClassOutput::write_option_,this,*itr));
}
Later on in the code, I actually want to call this collection of nullary function objects. I'm using a for loop here as well, and it seems like I should be able to use for_each somehow.
for(CallbackList::iterator itr = callbacks_.begin(); itr != callbacks_.end(); ++itr)
{
(*itr)();
}