error: static assertion failed: std::thread arguments must be invocable after conversion to rvalues
error: static assertion failed: std::thread arguments must be invocable after conversion to rvalues
我正在尝试将 std::function 添加到 std::thread,但我偶然发现了这个错误
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).
线程体的函数取整数,需要在线程启动时提供。
我正在尝试将 std::function 添加到 std::thread,但我偶然发现了这个错误
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).
线程体的函数取整数,需要在线程启动时提供。