Boost学习

 

  • 使用boost function使用类成员函数作为回调函数
#include <iostream>  
#include <boost/function.hpp>
struct MyTest { int foo(int a){ return a;}; }; int main(int argc, char *argv[]) { boost::function<int (int)> cb; X x; cb = std::bind1st(std::mem_fun(&X::foo), &x); std::cout<<cb(5)<<std::endl; return 0; }

 

posted @ 2019-08-20 08:46  mingzhang  阅读(377)  评论(0编辑  收藏  举报