boost-asio - 我有错误它的含义:错误 C2440 'return': cannot convert from 'void (__cdecl &)(yield_context)' to 'void (&)(yield_context)'
问题描述
我正在制作程序,在该程序中我尝试制作 boost packaged_task,然后将其未来放入向量中并使用 asio post 启动它。
当我尝试制作 packaged_task 时,它给了我这个错误:
Error C2440 'return': cannot convert from 'void (__cdecl &)(boost::asio::yield_context)' to 'void (&)(boost::asio::yield_context)'
这是相关代码:
typedef boost::packaged_task<std::string(boost::asio::yield_context)> task_t;
boost::shared_ptr<task_t> task = boost::make_shared<task_t>(boost::bind(&HTTPRequest::Execute, mClientRequestsVariables[m_HttpClient_request_name]->shared_from_this() , boost::placeholders::_1, m_HttpClient_request_name, Get_mHTTPClient_Responses_Map_shared_pointer()));
boost::future<std::string> fut = (task->get_future());
mPendingData.push_back(std::move(fut)); // C++11 possible: (std::move(fut) when fut is a unique_future);
mIos.post(boost::bind(&task_t::operator(), task));
这是 HTTPRequst::Execute 的定义:
HTTPRequest::HTTPRequest(boost::asio::io_service& ios, unsigned int id, std::string URL, const HTTPServiceResolve& resolve_addr, boost::shared_ptr<LoggingClass_2> mHTTPRequest_LoggingInstance_shared_pointer)
并且 HTTPRequest 类派生自 enable_shared_from_this 。
错误在 bind.hpp 中,所以我在 vs 输出窗口中找到了包含代码部分的线索。
为什么会发生这个错误?解决方案是什么?
解决方案
推荐阅读
- windbg - Windbg 脚本:有没有办法将当前执行的命令输出到日志中?
- c# - 如何从 asp.net web 应用程序检索数据到 windows 窗体应用程序(.net 框架)
- node.js - API Gateway 不将标头传递给 Lambda
- email - Exim 路由器配置失败
- ios - 将源添加到混音器时出现“抛出 -10878”
- python - 通过 Python 中的环境变量访问 API 的问题
- node.js - 动视网站的 Node.js 发布登录请求卡住了
- php - 如何使用 mpdf 库设置整页 pdf?
- c# - 在EOF c#Xabe.FFmpeg之后无法确定输入流0:0的格式
- python - 在 python 中合并两个 XML 后的漂亮打印