I create an object of type T in a template class.
template <class T>
class worker
{
public:
worker() { obj = new T(app_cfg);}
~worker() { if (obj) { delete obj; obj = nullptr; }}
void start();
private:
T * obj = nullptr;
std::atomic<bool> is_work_{ false };
std::thread thread_{};
};
The object has a check()
method. I want to run a check()
method on a thread. And I do it like this:
template <class T>
void worker<T>::start() {
is_work_ = true;
thread_ = std::thread(&T::check, obj, is_work_);
}
After that an error occurs:
Error C2661 no overloaded function taking 3 arguments
I think that the problem is in the thread launch syntax.
How to correctly specify the parameters for launch?