1

I have the following example:

class test 
{
public:
    void f() {}
};

std::shared_ptr<test> ptr = std::make_shared<test>();
std::thread t(*ptr, &test::f);

Basically I want a shared_ptr to a class and use thread to invoke a function on that ptr.
But compile is not happy here.

error C2893: Failed to specialize function template 'unknown-type std::invoke(_Callable &&,_Types &&...) noexcept(<expr>)'

Anything I am doing wrong here please?

Eduard Rostomyan
  • 7,050
  • 2
  • 37
  • 76
  • 3
    Your arguments are backwards. The first parameter is the member function to run, the next is the object to call it on, and any after that is the arguments for the member function itself if there are any. – NathanOliver Apr 13 '21 at 21:52

0 Answers0