gpt4 book ai didi

c++ - 错误 C2825 : 'F' : must be a class or namespace when followed by '::'

转载 作者:行者123 更新时间:2023-11-28 00:14:24 25 4
gpt4 key购买 nike

我在分析代码错误的原因时遇到了一些麻烦。我的代码看起来很好,其他开发人员也说很好:

void handle_read_headers(const boost::system::error_code& err, RESTClient::response& resp)
{
if (!err)
{
// 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)));

}
}

void handle_read_content(const boost::system::error_code& ec, size_t bytes_transferred, RESTClient::response& resp)
{
if (!ec)
{
// Write all of the data that has been read so far.
std::cout << &response_;

// Continue 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));
}
}

完整的源代码可以在这里找到:http://bit.ly/1gnemqG

错误是这样的

Error   1   error C2825: 'F': must be a class or namespace when followed by '::'    C:\local\boost_1_58_0\boost\bind\bind.hpp   69  1   HttpClientDemo
Error 2 error C2039: 'result_type' : is not a member of '`global namespace'' C:\local\boost_1_58_0\boost\bind\bind.hpp 69 1 HttpClientDemo
Error 3 error C2146: syntax error : missing ';' before identifier 'type' C:\local\boost_1_58_0\boost\bind\bind.hpp 69 1 HttpClientDemo
Error 4 error C2208: 'boost::_bi::type' : no members defined using this type C:\local\boost_1_58_0\boost\bind\bind.hpp 69 1 HttpClientDemo
Error 5 error C1903: unable to recover from previous error(s); stopping compilation C:\local\boost_1_58_0\boost\bind\bind.hpp 69 1 HttpClientDemo

这段代码可能有什么问题?

最佳答案

client::handle_read_content 中,对 boost::bind 的调用缺少参数。它应该与 client::handle_read_headers 中的相同:

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, // this line was missing
boost::ref(resp) // this line was missing
)
);

关于c++ - 错误 C2825 : 'F' : must be a class or namespace when followed by '::' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31290001/

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