当前位置:网站首页>std::enable_ shared_ from_ This error: error: expected template name before '<' token

std::enable_ shared_ from_ This error: error: expected template name before '<' token

2022-06-22 19:06:00 Chasing dreams - Polaris

enable_shared_from_this usage :

​​​​​​C++11 Ten new features :enable_shared_from_this_ Blog crawling on the grass -CSDN Blog

std::enable_shared_from_this - cppreference.com

During refactoring , In order to avoid the impact of the module being modified by others , Shielding some modules , As a result, the following error message appears , as follows :

../runtime/idm_client_proc_v2.h:70:86: error: expected template-name before ‘<’ token
   70 |   class CallbackWrapper : public idm::IIDMClient, public std::enable_shared_from_this<CallbackWrapper> {

Similar code snippets are as follows :


  class CallbackWrapper : public Client, public std::enable_shared_from_this<CallbackWrapper> {
   public:
    CallbackWrapper(const std::string& client_id, const std::string& identity, IDMClientProcV2* idm_client_proc);
}

After verification , The discovery is due to the lack of memory Caused by header file , And said this can only be used shared_ptr establish

enable_shared_from_this only works if the type was created as shared_ptr. Use:

Reference resources :https://www.reddit.com/r/cpp_questions/comments/kwhani/errors_while_using_stdenable_shared_from_this/

原网站

版权声明
本文为[Chasing dreams - Polaris]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206221728436733.html