错误C2039:'result_type的':不是''全局命名空间''成员 [英] error C2039: 'result_type' : is not a member of '`global namespace''

查看:1467
本文介绍了错误C2039:'result_type的':不是''全局命名空间''成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序抛出这个错误:

My app is throwing this error:

error C2039: 'result_type' : is not a member of '`global namespace''

这code:

void handle_read_headers(const boost::system::error_code& err, RESTClient::response& resp)
{
    if (!err)
    {
        // Process the response headers.
        std::istream response_stream(&response_);
        std::string header;
        while (std::getline(response_stream, header) && header != "\r")
            std::cout << header << "\n";
        std::cout << "\n";

        // Write whatever content we already have to output.
        if (response_.size() > 0)
            std::cout << &response_;

        (&resp)->body = "Yehey!!!";

        // Start reading remaining data until EOF.
        boost::asio::async_read(socket_, response_,
        boost::asio::transfer_at_least(1),
        boost::bind(&client::handle_read_content, this,
        boost::asio::placeholders::error, boost::ref(resp)));

    }
    else
    {
        std::cout << "Error: " << err << "\n";
    }
}

在绑定功能如下:

The "bound" function looks like this:

void handle_read_content(const boost::system::error_code& err, RESTClient::response& resp){}

怎么可能是错在我的code?

What could be wrong in my code?

更新:

我是能够编译code。与这些变化

I was able to compile the code with these changes

推荐答案

根据这个文档页面ReadHandler需要采取和错误code的以及的传输的字节数。

According to this documentation page ReadHandler needs to take and error code as well as the number of bytes transferred.

这可能是MSVC调用绑定前$ P $pssion.¹时更加挑剔/敏感有关丢失的占位符

It might be that MSVC is more picky/sensitive about the missing placeholders when invoking a bind expression.¹

尝试添加占位符参数绑定:

Try adding the placeholder parameter to the bind:

// Start reading remaining data until EOF.
boost::asio::async_read(socket_, response_,
        boost::asio::transfer_at_least(1),
        boost::bind(&client::handle_read_content, this,
            boost::asio::placeholders::error,
            boost::asio::placeholders::bytes_transferred,
            boost::ref(resp)));

和显然给处理函数本身太:

And obviously to the handler function itself too:

void handle_read_content(const boost::system::error_code& ec, size_t bytes_transferred, RESTClient::response& resp){}

更新

我已经花了大量不合理的努力(感谢@qballer,@nab,并在活饲料别人呢!)重现这个在Visual Studio和得到这个:

Update

I have spent unreasonable amounts of effort (thanks to @qballer, @nab, and others on the live feed too!) to reproduce this in Visual Studio and got this:

有关记录:这是


  • 的Win32

  • 升压1_58_0

  • 的OpenSSL 1.0.2c-I386-win32的

  • 的Visual Studio 2013更新4

¹其实我有时候注意到,短耳接受使用GCC(我的preferred编译器)处理函数略有不同的签名。我一直想知道这是否是一个功能,或者一个错误吗?

¹ in fact I've sometimes noticed that Asio accepts slightly different signatures for handler functions using GCC (my preferred compiler). I've always wondered whether that is a feature, or perhaps a bug?

这篇关于错误C2039:'result_type的':不是''全局命名空间''成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆