C++ boost asio异步读取文档

C++ boost asio异步读取文档,c++,boost-asio,C++,Boost Asio,示例和async\u read之间存在不一致。根据手册async\u read需要两个参数:错误代码和传输的字节数,但在示例中,处理程序只接受错误代码。这是怎么回事?既然可以,就用N个以上的参数调用bind object operator() #include <iostream> #include <boost/bind.hpp> template<typename T> void call(const T& f) { f(1, 2, 3,

示例和
async\u read
之间存在不一致。根据手册
async\u read
需要两个参数:错误代码和传输的字节数,但在示例中,处理程序只接受错误代码。这是怎么回事?

既然可以,就用N个以上的参数调用bind object operator()

#include <iostream>
#include <boost/bind.hpp>

template<typename T>
void call(const T& f)
{
   f(1, 2, 3, 4);
}

void f(int i) { std::cout << i << std::endl; }

int main()
{
   call(boost::bind(&f, 1));
}
#包括
#包括
模板
无效调用(常量T&f)
{
f(1,2,3,4);
}

void f(int i){std::cout,因为可以用N个以上的参数调用bind object操作符()

#include <iostream>
#include <boost/bind.hpp>

template<typename T>
void call(const T& f)
{
   f(1, 2, 3, 4);
}

void f(int i) { std::cout << i << std::endl; }

int main()
{
   call(boost::bind(&f, 1));
}
#包括
#包括
模板
无效调用(常量T&f)
{
f(1,2,3,4);
}

void f(int i){std::cout来自
boost::bind
的结果类型仍然满足的要求。的文档声明,额外的参数被静默忽略

例如,在Boost.Asio的内部,ReadHandler调用链可能类似于:

handler( error, bytes_transferred ) 
`-- binder::operator()( error, bytes_transferred )
    `-- bound_function( error )

<>为了更好地说明和解释<代码> BIN <代码>,请考虑阅读博客条目。它的一个例程具体说明了多余参数的情况。

< p>从Boo::Byp的结果类型仍然符合.'文档的要求]声明额外的参数被忽略。

例如,在Boost.Asio的内部,ReadHandler调用链可能类似于:

handler( error, bytes_transferred ) 
`-- binder::operator()( error, bytes_transferred )
    `-- bound_function( error )
<>为了更好地说明和解释<代码> BIN <代码>,请考虑阅读博客条目。它的一个例证具体说明了多余参数的情况。