C++ boost::绑定成员函数WriteHandlerCheck错误
我试图将一个函数绑定到C++ boost::绑定成员函数WriteHandlerCheck错误,c++,boost,boost-asio,function-pointers,C++,Boost,Boost Asio,Function Pointers,我试图将一个函数绑定到boost::asio::async\u write,但我在write.hpp中遇到了一个语义错误 受影响的代码: template <typename AsyncWriteStream, typename ConstBufferSequence, typename WriteHandler> inline BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler, void (boost::system::error
boost::asio::async\u write
,但我在write.hpp中遇到了一个语义错误
受影响的代码:
template <typename AsyncWriteStream, typename ConstBufferSequence,
typename WriteHandler>
inline BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
void (boost::system::error_code, std::size_t))
async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
{
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
detail::async_result_init<
WriteHandler, void (boost::system::error_code, std::size_t)> init(
BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
detail::write_op<AsyncWriteStream, ConstBufferSequence,
detail::transfer_all_t, BOOST_ASIO_HANDLER_TYPE(
WriteHandler, void (boost::system::error_code, std::size_t))>(
s, buffers, transfer_all(), init.handler)(
boost::system::error_code(), 0, 1);
return init.result.get();
}
很明显,我的经纪人都有问题。我就是不知道是什么,我真的被它惹恼了。在第一次异步写入中,您发送一个指向非静态成员函数的指针,而没有像在第二次写入中那样将其绑定到此指针
boost::asio::async_write(*s,boost::asio::buffer(&converted_number, sizeof(converted_number)),&Client::doNothing);
应该是
boost::asio::async_write(*s,boost::asio::buffer(&converted_number, sizeof(converted_number)),boost::bind(&Client::doNothing,this));
谢谢,这似乎在write.hpp中导致了两个错误,我疲惫的大脑自动将其与两个绑定联系起来,这两个绑定都是错误的。
// If you get an error on the following line it means that your handler does
// not meet the documented type requirements for a WriteHandler.
BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
boost::asio::async_write(*s,boost::asio::buffer(&converted_number, sizeof(converted_number)),&Client::doNothing);
boost::asio::async_write(*s,boost::asio::buffer(&converted_number, sizeof(converted_number)),boost::bind(&Client::doNothing,this));