Is there a C++/CLI smart pointer project (e.g. scoped_ptr)?

谁说胖子不能爱 提交于 2020-01-12 04:40:08

问题


Is there a C++/CLI RAII smart pointer class for containment of a native pointer in a managed type? Just wondering, before I go write my own clr_scoped_ptr value class template.

I'm aware of the Microsoft-provided:

  • containment of a managed handle in a native class: auto_gcroot

  • containment of a managed handle in a managed class: auto_handle

The above two are similar to auto_ptr or unique_ptr.

  • I gave skeleton code for a counted_handle here, similar to shared_ptr

But all these are for disposing managed ref class instances, not for freeing native objects.


回答1:


This one looks fairly complete, but I'm not looking for silent transfer of ownership ala auto_ptr.


I've posted my version under a rather permissive license over at codereview.se



来源:https://stackoverflow.com/questions/5454195/is-there-a-c-cli-smart-pointer-project-e-g-scoped-ptr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!