
15 Mar
2011
15 Mar
'11
2:17 p.m.
#include <iostream> #include <boost/bind.hpp> #include <boost/bind/protect.hpp> #include <boost/function.hpp> class test1 { public: template<typename S> double handle(S s) { s(1); std::cout<<"test1\n"; return 1; } template<typename F> void handle1(F f){ boost::bind(&test1::handle<boost::_bi::protected_bind_t<F>
,this, protect(f))();
} }; class test2 { public: double handle(int i) { std::cout<<"test2\n"; return i; } }; int main() { test2 t2; test1 t1; t1.handle1(boost::bind(&test2::handle,t2,_1)); return 0; }