Pocosharedptr smart pointer processing array method, pocosharedptr
Original article link
Poco SharedPtr has encountered some problems in the array processing process. For more information, see the official documentation for debugging and always report errors. After checking the source code, I finally found the problem and found many problems. In the case of source code, you can solve the problem by yourself through the source code. It may be because the official documents have not been updated for a long time. I hope you can read the source code in the future.
Template <class C> class ArrayReleasePolicy {public: static void release (C * pObj) // Delete the object. /// Note that pObj can be 0. {delete [] pObj ;}}; char * pStr = new char [100]; SharedPtr <char, Poco: ReferenceCounter, ArrayReleasePolicy> p (pStr );
The above use case provided by the official documentation is incorrect because the template requires the provision of data types
Template <class C> class ArrayReleasePolicy
The correct processing method should be:
Char * pStr = new char [100]; SharedPtr <char, Poco: ReferenceCounter, ArrayReleasePolicy <char> p (pStr );