В этой части кода из example:Почему `boost :: bind()` не может быть заменен на `std :: bind()` здесь?
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)
не работает?
Добавить все строки вашего сообщения об ошибке. –
'boost :: thread' имеет конструктор переадресации, поэтому вам не нужно связывать вообще:' boost :: thread t (& boost :: asio :: io_service :: run, &io); ' –