<分区>
这部分代码来自example :
int main()
{
boost::asio::io_service io;
printer p(io);
boost::thread t(boost::bind(&boost::asio::io_service::run, &io));
io.run();
t.join();
return 0;
}
如果我将 boost::bind(&boost::asio::io_service::run, &io)
替换为 std::bind(&boost::asio::io_service::run, &io)
我得到编译错误:
.../usr/lib/c++/v1/functional:1843:1: note: candidate template
ignored: couldn't infer template argument '_Fp'
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
^
/usr/lib/c++/v1/functional:1852:1: note: candidate template
ignored: couldn't infer template argument '_Rp'
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
^
1 error generated.
为什么会出现这个错误?
为什么 std::bind(&printer::print1, &p)
有效,但是 std::bind(&boost::asio::io_service::run, &io)
不起作用?