Starając się skompilować to w Visual C++ 2015std :: bind() Błąd: nie można ustalić, które instancja funkcji przeciążonej "boost :: asio :: io_service :: run" ma
auto worker = std::bind(&boost::asio::io_service::run, &(this->service));
I otrzymuję błędy:
error C2783: 'std::_Binder<_Ret,_Fx,_Types...> std::bind(_Fx &&,_Types &&...)': could not deduce template argument for '_Ret'
note: see declaration of 'std::bind'
error C2783: 'std::_Binder<_Ret,_Fx,_Types...> std::bind(_Fx &&,_Types &&...)': could not deduce template argument for '_Fx'
note: see declaration of 'std::bind'
error C2783: 'std::_Binder<std::_Unforced,_Fx,_Types...> std::bind(_Fx &&,_Types &&...)': could not deduce template argument for '_Fx'
note: see declaration of 'std::bind'
Dodatkowo IntelliSense narzeka:
cannot determine which instance of overloaded function "boost::asio::io_service::run" is intended
widzę, że są 2 przeciążenia boost::asio::io_service::run
. Ale jak mogę określić, którego użyć?
Z boost::bind
: kod kompiluje dobrze:
auto worker = boost::bind(&boost::asio::io_service::run, &(this->service));
Po prostu użyj znaku lambda ...> _> – ildjarn