Manually incrementing and decrementing a boost::shared_ptr?

前端 未结 7 1410
后悔当初
后悔当初 2021-01-05 22:57

Is there a way to manually increment and decrement the count of a shared_ptr in C++?

The problem that I am trying to solve is as follows. I am writing a library in C

相关标签:
7条回答
  • 2021-01-05 23:52

    You should do separation of concerns here: if the client passes in a raw pointer, the client will be responsible for memory management (i.e. clean up afterwards). If you create the pointers, you will be responsible for memory management. This will also help you with the DLL boundary issues that were mentioned in another answer.

    0 讨论(0)
提交回复
热议问题