I want to implement a small thread wrapper that provides the information if a thread is still active, or if the thread has finished its work. For this I need to pass the functio
In the error message, you can see the difference void (*)()
vs void (&)()
. That's because std::thread's constructor parameters are std::decay
ed.
Add also std::ref
to f
:
template< class Function, class... Args>
ManagedThread::ManagedThread( Function&& f, Args&&... args):
mActive( false),
mThread( threadFunction< Function, Args...>, std::ref(mActive), std::ref(f), std::forward(args)...)
{
}