gpt4 book ai didi

c++ - 使用 boost::signals2::signal 作为处理程序时出错

转载 作者:行者123 更新时间:2023-11-28 01:07:55 24 4
gpt4 key购买 nike

在下面的代码中:

   boost::signals2::signal<void(const boost::system::error_code&)> signal;
socket.async_connect(endpoint, boost::ref(signal));

(在 http://liveworkspace.org/code/e04910cbcc4cfd9e42e34d1af55c393e 找到)

我收到这个错误:

In file included from boost/asio/detail/wrapped_handler.hpp:18:0, from boost/asio/io_service.hpp:24, from boost/asio/basic_io_object.hpp:20, from boost/asio/basic_socket.hpp:19, from boost/asio/basic_datagram_socket.hpp:20, from boost/asio.hpp:20, from source.cpp:2: boost/asio/detail/bind_handler.hpp: In member function 'void boost::asio::detail::binder1< boost::reference_wrapper >, boost::system::error_code ::operator()()': boost/asio/handler_invoke_hook.hpp:64:3: instantiated from 'void boost::asio::asio_handler_invoke( boost::asio::detail::binder1< boost::reference_wrapper >, boost::system::error_code , ... )' boost/asio/detail/handler_invoke_helpers.hpp:39:3: instantiated from 'void boost_asio_handler_invoke_helpers::invoke( const boost::asio::detail::binder1< boost::reference_wrapper >, boost::system::error_code &, boost::reference_wrapper > & )' boost/asio/detail/bind_handler.hpp:73:3: instantiated from 'void boost::asio::detail ::asio_handler_invoke( const boost::asio::detail::binder1< boost::reference_wrapper >, boost::system::error_code &, boost::asio::detail::binder1< boost::reference_wrapper >, boost::system::error_code * )' boost/asio/detail/handler_invoke_helpers.hpp:39:3: instantiated from 'void boost_asio_handler_invoke_helpers::invoke( const boost::asio::detail::binder1< boost::reference_wrapper >, boost::system::error_code &, boost::asio::detail::binder1< boost::reference_wrapper >, boost::system::error_code & )' boost/asio/detail/completion_handler.hpp:63:7: instantiated from 'static void boost::asio::detail ::completion_handler< boost::asio::detail::binder1< boost::reference_wrapper >, boost::system::error_code

::do_complete( boost::asio::detail::boost::asio::detail::task_io_service *, boost::asio::detail::boost::asio::detail::task_io_service_operation *, boost::system::error_code, unsigned int )' boost/asio/detail/completion_handler.hpp:38:17: instantiated from 'boost::asio::detail ::completion_handler< boost::asio::detail::binder1< boost::reference_wrapper >, boost::system::error_code

::completion_handler( boost::asio::detail::binder1< boost::reference_wrapper >, boost::system::error_code

)' boost/asio/detail/impl/task_io_service.hpp:50:3: instantiated from 'void boost::asio::detail ::task_io_service::post( boost::asio::detail::binder1< boost::reference_wrapper >, boost::system::error_code

)' boost/asio/impl/io_service.hpp:80:3: instantiated from 'void boost::asio::io_service::post(Handler)' boost/asio/basic_socket.hpp:649:9: instantiated from 'void boost::asio::basic_socket< boost::asio::ip::tcp, boost::asio::stream_socket_service ::async_connect( boost::asio::basic_socket >::boost ::asio::ip::basic_endpoint &, boost::reference_wrapper> )' source.cpp:10:53: instantiated from here boost/asio/detail/bind_handler.hpp:40:5: error: no match for call to '( boost::reference_wrapper> ) (const boost::system::error_code &)'

最佳答案

您的签名好像有误?您需要为错误代码指定一个占位符

尝试

boost::signals2::signal<void(const boost::system::error_code&)> signal;
socket.async_connect(endpoint, boost::bind(boost::ref(signal), _1));

关于c++ - 使用 boost::signals2::signal 作为处理程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5148358/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com