
#include <iostream> #include <boost/bind.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<F>,this,f)(); } }; class test2 { public: double handle(int i) { std::cout<<"test2\n"; return i; } }; int _tmain(int argc, _TCHAR* argv[]) { test2 t2; test1 t1; t1.handle1(boost::bind(&test2::handle,t2,_1)); return 0; } in test1::handle1 complie fail on vs2010 and gcc 4.4.1 vs 2010 error:error C2664: "R boost::_mfi::mf1<R,T,A1>::operator ()<test1>(const U &,A1) const": can't convert "double"to "boost::_bi::bind_t<R,F,L>" . but boost::bind(&test1::handle<F>,this,f)(); f is not double,f is bind_t and double only return_type. by the way,boost::bind(&test1::handle<F>,this,boost::ref(f))(); can work.