std::_Bind std::function void(std::shared_ptr xxxx ) (xxxx*)

required from ‘void AsyncInvoker::invoke(Callable&&) [with Callable = std::_Bind<std::function<void(std::shared_ptr<xxxx>)>(xxxx*)>]’

報這個錯誤,是需要進行共享指針和普通指針轉換

https://www.cnblogs.com/tyche116/p/9626396.html

struct test
{
     int num;
     string name;
};

test* pTest = new test();
std::shared_ptr<test> ptr_test = std::shared_ptr<test>(pTest); //普通指針轉shared_ptr

std::shared_ptr<test> ptr_test2 = std::make_shared<test>();
test* pTest2 = ptr_test2.get(); //shared_ptr轉普通指針

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章