boost:asio:read_until问题与boost::bind有关
boost:asio:read_until issue with boost::bind
我在编译这段代码时遇到问题错误
/usr/include/boost/bind_mf_cc.hpp:91:5:错误:初始化'boost::_bi::bind_t的参数5,typename boost::_blai::list_av_4::type>boost:;bind(R(t::*)(B1,B2,B3),A1,A2,A3,A4)[其中R=void;T=tcpReader;B1=const boost::system::error_code&B2=unsigned int;B3=boost::asio::basic_streambuf<>&A1=tcpReader*;A2=boost::system:;error_code;A3=unsignedint;A4=boost::asic_streambuf<>;typename boost:_bi::list_av_4:type=boost _bi::value>>]
void tcpReader::handle_read(const boost::system::error_code& ec, std::size_t bytes_transferred, boost::asio::streambuf& buf)
// inside a class method
boost::asio::streambuf buf;
boost::asio::async_read_until(*sock,buf,"n" ,
boost::bind(&tcpReader::handle_read,this,error,buf.size(),buf)
);
有什么问题吗?我知道我错过了一些简单的东西,但我不知道是不是我必须使用boot::buffer?
提前感谢
对我来说,async_read_until()的所有重载都需要两个参数。您传递一个有3个参数的函数。如果您想将流作为额外的参数传递,请将其绑定到函数以获得一个具有2个参数的函数。
boost::bind( &tcpReader::handle_read, this, _1, _2, boost::ref( buf ) )
将您的成员函数"转换"为某种东西,需要2个参数。boost::ref()将缓冲区包装为引用,否则将生成一个副本。
亲切问候Torsten
相关文章:
- 理解boost::asio-async_read在无需读取内容时的行为
- boost::进程间消息队列引发错误
- 如何运行位于boost/libs/python/example/tutorial目录中的hello.cpp和Jamfil
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- cmake如何在fedora工作站中找到boost静态库包
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- Boost Graph Library,修复节点大小
- 什么是"#include <boost/functional/hash.hpp> "?
- 基于boost的程序的静态链接——zlib问题
- C++:如何在CLion IDE中安装Boost
- clang编译错误与static_assert和boost :: hana有关
- 当我使用py 生成时,然后在macOS上boost.python包装器时,我会发现有关std :: string的错
- 如何修复与Xtime的Boost和Vs相互冲突的定义有关的编译器错误
- 有关使用 boost::variant 重新加载运算符的编译错误
- 有关使用 boost 生成正常随机数的问题
- boost:asio:read_until问题与boost::bind有关
- 为什么 boost::p rogram_options 在定义默认值时会抛出有关必需参数的错误
- 在Qt中使用boost会抛出有关信号被定义为受保护的错误
- 有关boost.log和boost.build(bjam)别名、构建和包含在目标中的帮助