функцияк тому, что возвращается boost :: bind () - PullRequest
0 голосов
/ 04 декабря 2018

, поэтому в приложении C ++ есть нестатическая функция-член, на которую ссылается function<void(void)>.Мне нужно вызвать его с помощью таймера повышения, используя boost::asio::deadline_timer.async_wait(callback).Пока timer.async_wait(callback) выдает эту ошибку

In file included from /usr/include/boost/asio/impl/io_service.hpp:18:0,
                 from /usr/include/boost/asio/io_service.hpp:767,
                 from /usr/include/boost/asio/basic_io_object.hpp:19,
                 from /usr/include/boost/asio/basic_socket.hpp:20,
                 from /usr/include/boost/asio/basic_datagram_socket.hpp:20,
                 from /usr/include/boost/asio.hpp:21,
                 from /home/foo/NetBeansProjects/ceuis-g3/Timer.h:20,
                 from /home/foo/NetBeansProjects/ceuis-g3/Timer.cpp:9:
/usr/include/boost/asio/basic_deadline_timer.hpp: In instantiation of ‘typename boost::asio::async_result<typename boost::asio::handler_type<ConnectHandler, void(boost::system::error_code)>::type>::type boost::asio::basic_deadline_timer<Time, TimeTraits, TimerService>::async_wait(WaitHandler&&) [with WaitHandler = std::function<void()>&; Time = boost::posix_time::ptime; TimeTraits = boost::asio::time_traits<boost::posix_time::ptime>; TimerService = boost::asio::deadline_timer_service<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime> >; typename boost::asio::async_result<typename boost::asio::handler_type<ConnectHandler, void(boost::system::error_code)>::type>::type = void]’:
/home/foo/NetBeansProjects/ceuis-g3/Timer.cpp:24:29:   required from here
/usr/include/boost/asio/basic_deadline_timer.hpp:505:5: error: static assertion failed: WaitHandler type requirements not met
     BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
     ^
/usr/include/boost/asio/basic_socket.hpp:754:5: error: no match for call to ‘(std::function<void()>) (const boost::system::error_code&)’
     BOOST_ASIO_CONNECT_HANDLER_CHECK(ConnectHandler, handler) type_check;
     ^
In file included from /usr/include/c++/7/functional:58:0,
                 from /home/foo/NetBeansProjects/ceuis-g3/Timer.h:18,
                 from /home/foo/NetBeansProjects/ceuis-g3/Timer.cpp:9:
/usr/include/c++/7/bits/std_function.h:701:5: note: candidate: _Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = void; _ArgTypes = {}]
     function<_Res(_ArgTypes...)>::
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/std_function.h:701:5: note:   candidate expects 0 arguments, 1 provided

Объявление async_wait выглядит следующим образом

template <typename WaitHandler>
  BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
      void (boost::system::error_code))
  async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)

Я из Явы, я понятия не имею, что все это значит.Как преобразовать одно представление члена в другое?

РЕДАКТИРОВАТЬ: Ответ в комментариях Лилисент.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...