Hi All
In the code below my objective is pass a nullary function object to apply, and for that
nullary function object to be 'my_function()' called with each member of the vector. How can I
recode the call to apply as a unary bind expression such that I can write the for loop
as a for_each loop?
Thx,
- Rob.
#include <vector>
#include "boost/function.hpp"
#include "boost/bind.hpp"
void apply( boost::function<void()> f )
{
f( );
}
int main( )
{
static boost::function<void(int)> my_function = 0;
std::vector<int> v;
for ( std::vector<int>::iterator i = v.begin( ); i != v.end( ); ++ i )
{
apply( bind( my_function, * i ) );
}
}