在asio spawn调用中提升与成员函数的绑定

boost bind with member function in asio spawn call

在下面的代码中我制作了地图,
然后向其中添加一些 httprequest class 个实例,
然后我使用 httprequest class,
的成员函数调用 boost asio spawn 我之前问过这个并告诉它是重复的,
所以我阅读了 post 并进行了一些挖掘,发现了以下内容:
我必须使用 boost::bind 将成员函数及其参数转换为单个函数对象。
在 boost 绑定中,我必须添加该方法在其上运行的实例的地址,并且方法地址“如果方法地址来自 class 定义或来自已使用的实例,
,则不会获取 然后添加参数。 我的地图有由共享指针表示的 httprequests。
当我编写并编译它时,它给了我很多与绑定相关的错误。
问题是在代表我的代码的绑定文件中,但没有说明有问题的部分。

代码如下:

std::map<std::string, boost::shared_ptr<HTTPRequest>> requests_variables;
std::map<std::string, boost::shared_ptr<HTTPResponse>> tasks;    

for (int hour = 0;hour < 24;hour++)
{
    std::stringstream ss_hour;
    ss_hour << std::setw(2) << std::setfill('0') << hour;
    std::string url_hour{ ss_hour.str() };
    std::stringstream().swap(ss_hour); // swap m with a default constructed stringstream
    URL = URL + url_hour +"h_ticks.bi5";

    std::string request_name = "request_" + std::to_string(hour);
    requests_variables[request_name] =  client.create_request(hour, URL);       
    boost::asio::spawn(client.get_service_reference(), boost::bind(&(*requests_variables[request_name]),&(*requests_variables[request_name]).execute, boost::placeholders::_1, tasks, request_name, requests_variables));

我试图多次操纵它以使其编译但徒劳无功。
绑定有问题,但我无法访问它。
提前致谢..

我不知道为什么,但这让它起作用了。

HTTPRequest* requst_z = requests_variables[request_name].get();

        boost::asio::spawn(client.get_service_reference(), boost::bind(&HTTPRequest::execute, requst_z, boost::placeholders::_1, tasks, request_name, requests_variables));