普通成员函数的调用参数问题
windflowerly opened this issue · 6 comments
windflowerly commented
你好。
bind: .commit(std::bind(&Dog::sayHello, &dog))
这个好像不能带参数。
qhq16 commented
参数带在bind里啊,为什么不能带参数
windflowerly commented
晓得了。参数类型问题。
ZhuZouRong commented
这个是只能调用threadpool自己的成员函数吗
qhq16 commented
用bind绑定类成员函数就可以使用commit了
ZhuZouRong commented
namespace dao
{
class Impl : public IStore
{
public:
virtual int del(const std::string& strId);
};
std::threadpool executor;
std::future test = executor.commit(std::bind(&dao::Impl::del, "id"));
是这样调用吗
编译报错 required from here
/usr/include/c++/5/functional:1426:7: error: static assertion failed: Wrong number of arguments for pointer-to-member
static_assert(_Varargs::value
qhq16 commented
bind绑定非静态成员函数需要类对象指针,而且你绑定的是虚函数,你可以看看bind的用法