C++ 如何在一系列boost::function对象上使用std::for_? 类用户 { 公众: 用户(){} 虚拟~User(){} 无效测试(int-in) { } } 用户; 向量函数; push_back(boost::bind(&User::Test,&User,2)); push_back(boost::bind(&User::Test,&User,4)); 对于每个函数(functions.begin()、functions.end()、/*这里是什么?*/);

C++ 如何在一系列boost::function对象上使用std::for_? 类用户 { 公众: 用户(){} 虚拟~User(){} 无效测试(int-in) { } } 用户; 向量函数; push_back(boost::bind(&User::Test,&User,2)); push_back(boost::bind(&User::Test,&User,4)); 对于每个函数(functions.begin()、functions.end()、/*这里是什么?*/);,c++,boost,boost-bind,boost-function,C++,Boost,Boost Bind,Boost Function,试试看 for_each(functions.begin()、functions.end()、mem_fn(&function::operator()); 其中mem\u fn是std::tr1::mem\u fn或boost::mem\u fn class User { public: User(){} virtual ~User(){} void Test( int in ) { } } U

试试看

for_each(functions.begin()、functions.end()、mem_fn(&function::operator());
其中
mem\u fn
std::tr1::mem\u fn
boost::mem\u fn

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? */ );
for_each( functions.begin(), functions.end(), mem_fn( &function< void() >::operator() ) );