在 stream_descriptor::async_wait 中无效使用非静态成员函数
invalid use of non-static member function in stream_descriptor::async_wait
Debian Linux, Boost 1.67. 以编码 boost::asio::p osix::stream_descriptor::async_wait 为例,并将我放在一个类中,我在async_wait行的wait_handler上得到"无效使用非静态成员函数"。
提升示例
void wait_handler(const boost::system::error_code& error)
{
if (!error)
{
// Wait succeeded.
}
}
...
boost::asio::posix::stream_descriptor descriptor(io_context);
...
descriptor.async_wait(
boost::asio::posix::stream_descriptor::wait_read,
wait_handler);
转换为
void EHandler::wait_handler(const boost::system::error_code& error)
{
if (!error)
{
// Wait succeeded.
}
}
void EHandler::StartRead()
{
...
boost::asio::posix::stream_descriptor descriptor(io_context);
descriptor.async_wait(boost::asio::posix::stream_descriptor::wait_read, wait_handler);
}
试:
... wait_handler, this);
... EHandler::wait_handler);
... &EHandler::wait_handler);
... EHandler::wait_handler, this);
... &EHandler::wait_handler, this);
... boost::bind() with each of the above options
甚至尝试将 _1( 添加到每个。 我忽略了什么?
由于此例程将从最多 8 个线程调用,因此不能将其声明为静态,这是对错误消息修复的建议。
尚未完全测试,这只是通过编译器错误。
descriptor.async_wait(boost::asio::p osix::stream_descriptor::wait_read, boost::bind(&EHandler::wait_handler, this, boost::asio::p laceholders::error((;
相关文章:
- 如何在C++中使用非静态成员函数作为回调函数
- 静态成员函数使用相同的名称时出现模板类型名称错误
- 在 nullptr 上调用无状态类的非静态成员函数是否合法?
- 为什么传递非静态成员函数会导致编译错误?
- 处理类内的回调时,必须调用对非静态成员函数的引用
- 非静态成员函数的 decltype 格式不正确吗?
- std::异步与非静态成员函数
- C++无效使用非静态成员函数?
- 未使用的C++未优化的静态成员函数/变量
- C++:如何返回指向非静态成员函数的指针?
- 使用静态成员函数而不是普通函数是否有任何开销?
- 在 stream_descriptor::async_wait 中无效使用非静态成员函数
- 为什么我不能像这样在静态成员函数中调用静态成员变量?
- 无法在clang Linux中分配非静态成员函数,但我可以在Visual Studio Windows中分配
- 在类定义中推导内联静态成员函数的返回类型
- `enable_if()`以禁用模板化类的静态成员函数声明
- 错误:无效使用非静态成员函数"int test::hotplug_callback(libusb_contex
- 常量静态成员函数
- 使用 vector.sort() 的非静态成员函数无效使用
- 从静态成员函数访问私有非静态类变量 - C++