If the method needs ownership a, pass it through the heap, preferably in shared_ptr:
void foo(std::shared_ptr<MyClass> a) {}
[...]
auto a_ptr = std::make_shared<MyClass>();
std::thread t(foo, a_ptr);
Otherwise, just pass it by reference:
void foo(MyClass& a) {}
[...]
MyClass a;
std::thread(foo, std::ref(a));
source
share