I am trying to add a std::function to std::thread and i stumble upon this error
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;
}
Why is this not working?
The initial integer value is missing when thread ctor is called: thread(std::ref(tfunc), 123).
Function of thread body takes integer, you need to provide it when thread starts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With