我正在尝试向 std::thread 添加 std::function ,我偶然发现了这个错误
error: static assertion failed: std::thread arguments must be invocable after conversion to rvalues
struct Foo {
explicit Foo(const std::function<void(int)>& tfunc)
: thread(tfunc) { //<----- error points here
thread.join();
}
std::thread thread;
}
为什么这不起作用?
调用线程构造函数时缺少初始整数值:thread(std::ref(tfunc), 123)。
线程体的函数需要整数,您需要在线程启动时提供它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)