2
class User    
{    
public:

    User(){}    
    virtual ~User(){}
    void Test( int in )    
    {    
    }    
}    

User user;

vector< boost::function< void() > > functions;

functions.push_back( boost::bind( &User::Test, &user, 2 ) );

functions.push_back( boost::bind( &User::Test, &user, 4 ) );

for_each( functions.begin(), functions.end() , /* What goes here? */ );
4

1 回答 1

3

尝试

for_each( functions.begin(), functions.end(), mem_fn( &function< void() >::operator() ) );

要么mem_fn要么。std::tr1::mem_fn_boost::mem_fn

于 2011-11-21T19:46:09.037 回答