Boost::bind 绑定重载运算符问题
我有一个 [] 运算符重载的类。我也有一个线程要开始... 如何将 [] 绑定到线程?
我试过这个:
<代码> threadpool.schedule( bind( static_cast< MyClass (MyClass::*)(const MyClass &arg )>( &MyClass::operator[]), arg ) )
但 VS2008 说:
错误 C2664:
'boost::threadpool::thread_pool::schedule': cannot convert parameter 1 from 'boost::_bi::bind_t' to 'const boost::function0 &'
我该如何解决这个问题?先感谢您。
I've a class with [] operator overloaded. I also have a thread to start...
How can I bind [] to the thread?
I tried this:
threadpool.schedule( bind( static_cast< MyClass (MyClass::*)(const MyClass &arg )>( &MyClass::operator[]), arg ) )
but VS2008 says:
error C2664:
'boost::threadpool::thread_pool::schedule': cannot convert parameter 1 from 'boost::_bi::bind_t' to 'const boost::function0 &'
How can i resolve this? Thank you in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来不对。您的成员函数仍然接受一个参数。所以你需要一个占位符,或者你忘记绑定
this
接受其类类型的
operator[]
看起来有点奇怪。这是一个如何查找“常用”下标运算符的示例That looks wrong. Your member function still accepts one argument. So you need a placeholder, or you forgot to bind
this
An
operator[]
that accepts its class type looks a bit weird though. Here is an example how it should look for a "usual" subscript operator