Open Capsfly opened 1 year ago
是不带参数的,你可以用std::bind或者lambda捕获局部变量来传入参数。
我试了一下,好像不行呀,up能给个例子嘛? 这是compute函数的定义
#include <hipe/hipe.h>
double func(double x) {
hipe::util::print("hello world");
return x;
}
int main() {
hipe::SteadyThreadPond poo(10);
auto tmp = poo.submitForReturn(std::bind(func, 2.5));
poo.waitForTasks();
hipe::util::print(tmp.get());
}
没问题呀
jack@LAPTOP-9HN8DLAB:~/code/Hipe/interfaces$ g++ tmp.cc -I ../include -lpthread && ./a.out
hello world
2.5
如题,可以看出这个函数是不是只实现了 执行不带参数的函数功能啊?因为在调用std::result_of和std::packaged_task的时候,模板里面都没加参数的类型。如果我理解错误的话,up方不方便给一个普通函数的例子啊?