库定义了不透明的数据类型:
\n\nstruct OpaqueStruct;\nRun Code Online (Sandbox Code Playgroud)\n\n并且客户端代码必须获取并释放OpaqueStruct*. 我可以访问库源。
不幸的是,既不能存储该指针shared_ptr,也unique_ptr不能存储该指针,从而出现错误: invalid application of \xe2\x80\x98sizeof\xe2\x80\x99 to incomplete type。
我能想到的最好的办法就是从这篇文章中借用finally守卫 。
\n\n如何将 RAII 用于不透明结构指针?
\n